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 |
大家帮忙看看我的程序,为什么总是wa啊#include <stdio.h> #include <iostream> #include <stdlib.h> using namespace std; int main() { int num,i,j,cycles,t; int squeue[250],cycle[250]; char s[250],stemp[250]; while (1) { scanf("%d",&num); if(num==0) break; for (i=1;i<=num;i++) scanf("%d",&squeue[i]); for (i=1;i<=num;i++) { j=1; t=i; while(squeue[t]!=i) { t=squeue[t]; j++; } cycle[i]=j; } while (1) { scanf("%d ",&cycles); if(cycles==0) { printf("\n"); break; } memset(s,' ',sizeof(s)); i=1; while (1) { scanf("%c",&s[i]); if(s[i++]=='\n') break; } s[i-1]=' '; s[num+1]='\0'; memset(stemp,' ',sizeof(stemp)); for (i=1;i<=num;i++) { t=cycles%cycle[i]; int temp=i; for(j=1;j<=t;j++) temp=squeue[temp]; stemp[temp]=s[i]; } stemp[num+1]='\0'; printf("%s\n",stemp+1); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator