View Code of Problem 3309

#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct Chi{
	string name;
	int id;
};
int main(){
	int N;
	while(cin>>N){
		Chi ar[70];
		for(int i=1;i<=N;i++){
			cin>>ar[i].name;
			ar[i].id=1;
		}
		int w,s;
		scanf("%d,%d",&w,&s);
		queue<Chi>q;
		for(int i=w,j=0;j<N;j++){
			q.push(ar[i]);
			//cout<<ar[i].name<<endl;
			i++;
			if(i>N){
				i=1;
			}
		}
		int num=1;
		while(!q.empty()){
			Chi cur=q.front();
			//cout<<cur.name<<endl;
			q.pop();
			if(num==s){
				cout<<cur.name<<endl;
				num=1;
			}
			else{
				num++;
				q.push(cur);
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 3309