View Code of Problem 3309

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define inf 0x7fffffff

typedef struct{
	char name[17];
}Stu; 

int main() {
	int n,w,s;
	scanf("%d",&n);
	Stu stu[100000];
	int x=n;
	for(int i=1;i<=n;i++){
		scanf("%s",stu[i].name);
	}
	scanf("%d,%d",&w,&s);
	int cnt=1;
	for(int i=1;i<w;i++){
		strcpy(stu[++n].name,stu[i].name);
	}
	for(int i=w;x!=0;i++){
		if(cnt%s==0){
			printf("%s\n",stu[i].name);
			x--;
			cnt=1;
		}else{
			strcpy(stu[++n].name,stu[i].name);
			cnt++;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3309