View Code of Problem 3309

#include<stdio.h>
#include<string.h>
typedef struct{
	char name[20];
	int flag ;
}child;
int main(){
	int n;
	scanf("%d",&n);
	child a[n];
	int i,j;
	for(i = 0;i < n; i++){
		scanf("%s",a[i].name);
		a[i].flag = 1;
	}
	int w,s;
	scanf("%d,%d",&w,&s);
	int sum = n,num = 0;
	char temp[n][20];
	int count = 0;
	for(i = w-1;sum>0; i++){
		if(a[i%n].flag){
			count++;
			if(count%s == 0){
				strcpy(temp[num++],a[i%n].name);
				a[i%n].flag = 0;
				sum--;
			}
		}
	}
	for(i = 0;i < n; i++){
		printf("%s\n",temp[i]);
	}
}

Double click to view unformatted code.


Back to problem 3309