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> #define M 10000 int main() { int T; char string[M][16],number[M][10]; char ch[10]; int i,j,k,len1,len2; int num[M],n,t,m,min; while(scanf("%d",&T)!=EOF) { for(i=0;i<T;i++) { k=0; num[i]=1; scanf("%s",string[i]); len1=strlen(string[i]); for(j=0;j<len1;j++) { if(string[i][j]=='-'||k==3) { if(k==3) { number[i][k++]='-'; if(string[i][j]!='-') j--; } else continue; } else if(string[i][j]>=65&&string[i][j]<=90) { if(string[i][j]>='A'&&string[i][j]<='C') number[i][k++]='2'; else if(string[i][j]>='D'&&string[i][j]<='F') number[i][k++]='3'; else if(string[i][j]>='G'&&string[i][j]<='I') number[i][k++]='4'; else if(string[i][j]>='J'&&string[i][j]<='L') number[i][k++]='5'; else if(string[i][j]>='M'&&string[i][j]<='O') number[i][k++]='6'; else if(string[i][j]>='P'&&string[i][j]<='S') number[i][k++]='7'; else if(string[i][j]=='T'||string[i][j]=='U'||string[i][j]=='V') number[i][k++]='8'; else number[i][k++]='9'; } else number[i][k++]=string[i][j]; } if(i==0) num[i]=1; else for(n=0;n<i;n++) if(strcmp(number[n],number[i])==0) { num[i]++; num[n]=1; } number[i][k]='\0'; } for(i=0;i<T-1;i++) { if(num[i]==1) continue; else { k=i; for(j=i+1;j<T;j++) { if(num[j]==1) break; else { if(strcmp(number[k],number[j])>0) k=j; } } if(k!=i) { t=num[i]; num[i]=num[k]; num[k]=t; strcpy(ch,number[i]); strcpy(number[i],number[k]); strcpy(number[k],ch); } } } for(i=0;i<T;i++) if(num[i]!=1) printf("%s %d\n",number[i],num[i]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator