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 |
看了许多的discuss,似乎各处都注意了,但还是WA。为什么啊??#include<stdio.h> viod main() { char array1[100],array2[100],array3[100],array4[100]; //为了防止意外溢出,数组都做大了些 char index[50][300]; //之前按所需+1来的,也没有AC int i,j; for(i=0;i<=26;i++) for(j=0;j<300;j++) index[i][j]=' '; int idx[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; gets(array1);gets(array2);gets(array3);gets(array4); for(i=0;i<72;i++) //将适当的地方变为'*' { if(array1[i]>=65&&array1[i]<=90) { index[array1[i]-65][idx[array1[i]-65]]='*'; idx[array1[i]-65]++; } } for(i=0;i<72;i++) { if(array2[i]>=65&&array2[i]<=90) { index[array2[i]-65][idx[array2[i]-65]]='*'; idx[array2[i]-65]++; } } for(i=0;i<72;i++) { if(array3[i]>=65&&array3[i]<=90) { index[array3[i]-65][idx[array3[i]-65]]='*'; idx[array3[i]-65]++; } } for(i=0;i<72;i++) { if(array4[i]>=65&&array4[i]<=90) { index[array4[i]-65][idx[array4[i]-65]]='*'; idx[array4[i]-65]++; } } int max=0; for(i=0;i<26;i++) { if(idx[i]>max)max=idx[i]; } max--; int re; for(;max>=0;max--) { for(i=0;i<=26;i++) { re=0; for(j=i;j<=26;j++) { if(index[j][max]=='*')re=1; } if(re==0){printf("\n");break;} printf("%c",index[i][max]); //输出"*"或空格 i++; re=0; for(j=i;j<=26;j++) { if(index[j][max]=='*')re=1; } if(re==0){i--;printf("\n");break;} //判断最后一行不输出空格 i--; printf(" "); } } printf("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator