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 |
狠狠的鄙视自己。既然忘记考虑特殊情况 ,报数间隔为1的情况附代码 #include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ char **name; int i,n,j,k,start,out,live; scanf("%d",&n); name=(char **)malloc(n*sizeof(char *)); for(i=0;i<n;i++){ name[i]=(char *)malloc(16*sizeof(char)); scanf("%s",name[i]); } scanf("%d,%d",&start,&out); live=n;k=0;j=start-2; while(live>=1){ while(1){ j=(j+1)%n; if(name[j][0]!='!') k++; if(k==out){ printf("%s\n",name[j]); name[j][0]='!'; k=0; break; } } live--; } for(i=0;i<n;i++) free(name[i]); free(name); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator