View Code of Problem 3309

#include <stdio.h>
#include <string.h>
 
typedef struct Data{
	char name[15];
	int flag;
}Data;
 
int main(){
	int n,i,w,s,cnt=0,out=0;
	scanf("%d",&n);
	Data a[n];
	for(i=0;i<n;i++){
		scanf("%s",&a[i].name);
		a[i].flag=0;		
	}
	scanf("%d,%d",&w,&s);
	i=w-1;
	while(out<n){
		if(a[i].flag==0)			
        {
			cnt++;
			if(cnt==s){
				printf("%s\n",a[i].name);
				cnt=0;
				out++;
				a[i].flag=1;
			}
		}
		i++;
		if(i>=n)
			i=0;
	}
}

Double click to view unformatted code.


Back to problem 3309