| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
又是一道水淋淋的题目啊!#include <stdio.h> struct children { int num; char name[100]; }; int main() { struct children ch[1000]; int i,k,w,s,res,cur,ord; scanf("%d",&k); getchar(); for(i=0; i<k; i++) { gets(ch[i].name); ch[i].num=1; } scanf("%d,%d",&w,&s); res=k; cur=w-1; ord=1; while(res>1) { while(ch[cur].num==0) { cur=(cur+1)%k; } if(ord==s) { ch[cur].num=0; ord=0; res--; puts(ch[cur].name); } cur=(cur+1)%k; ord++; } for(cur=0; cur<k; cur++) { if(ch[cur].num!=0) { puts(ch[cur].name); break; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator