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<string.h> int main() { char key[15],ip[105],turn[15][15],i; int j,a,b,keylen,iplen,p; while(scanf("%s",key)!=EOF && strcmp(key,"THEEND")){ scanf("%s",ip); keylen=strlen(key); iplen=strlen(ip); b=iplen/keylen; p=0; for(i='A';i<='Z';i++) for(j=0;key[j];j++) if(i==key[j]) for(a=0;a<b;a++,p++) turn[a][j]=ip[p]; for(i=0;i<b;i++)//以字符一个一个地输出 for(j=0;j<keylen;j++) printf("%c",turn[i][j]); puts(""); } return 0; } 这样就过不了: #include "stdio.h" #include<string.h> int main() { char key[15],ip[105],turn[15][15],i; int j,a,b,keylen,iplen,p; while(scanf("%s",key)!=EOF && strcmp(key,"THEEND")){ scanf("%s",ip); keylen=strlen(key); iplen=strlen(ip); b=iplen/keylen; p=0; for(i=0;i<keylen;i++) //上面的程序修改的是这个地方,这里是当成字符串来输出,上面是一个一个字符地输出 turn[i][keylen]=0; for(i='A';i<='Z';i++) for(j=0;key[j];j++) if(i==key[j]) for(a=0;a<b;a++,p++) turn[a][j]=ip[p]; for(i=0;i<b;i++)//以字符串一个单位一个单位地输出 printf("%s",turn[i]); puts(""); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator