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的,麻烦高手帮忙看一下!//WA #include <stdio.h> #include <string.h> int main() { char D[10005][50],C[100][50],A[50],m; int i,j,k,n,lend,rlend,rlenc,f[100],d[10005],index,temp; freopen("acm.txt","r",stdin); for(i=0;i<10005;i++) { scanf("%s",D[i]); if( D[i][0]=='#' ) break; } lend=i; for(i=0;i<100;i++) { scanf("%s",C[i]); rlenc=strlen(C[i]); if( C[i][0]!='#' ) { index=0; for(j=0;j<lend;j++) { f[i]=0; rlend=strlen(D[j]); if( rlend==rlenc ) { strcpy(A,C[i]); if( !strcmp(A,D[j]) ) { f[i]=1; break; } } if( f[i]==0 ) { if( rlend==rlenc )// 1 { for(k=0;k<rlenc;k++) { strcpy(A,C[i]); for(m='a';m<='z';m++) { if( D[j][k]==m ) { A[k]=m; // if( !strcmp(A,D[j]) ) { d[index]=j; index++; } } } } }// 1 if( rlend==rlenc+1 )// 2 { for(k=0;k<=rlenc;k++) { strcpy(A,C[i]); for(m='a';m<='z';m++) { if( D[j][k]==m ) { for(n=rlenc+1;n>k;n--) A[n]=A[n-1]; A[k]=m; // if( !strcmp(A,D[j]) ) { d[index]=j; index++; } } } } }// 2 if( rlend==rlenc-1 )// 3 { for(k=0;k<rlenc;k++) { strcpy(A,C[i]); for(n=k;n<rlenc+1;n++) A[n]=A[n+1]; if( A[k]==D[j][k] ) { if( !strcmp(A,D[j]) ) { d[index]=j; index++; // printf(" %s",D[j]); } } } }// 3 } } if( f[i]==1 ) { printf("%s is correct\n",C[i]); continue; } if(index!=0) { for(k=0;k<index;k++) { for(n=index-1;n>k;n--) { if( d[n-1]>d[n] ) { temp=d[n]; d[n]=d[n-1]; d[n-1]=temp; } } } printf("%s:",C[i]); for(k=0;k<index;k++) printf(" %s",D[d[k]]); } else printf("%s:",C[i]); printf("\n"); } else 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