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 "stdlib.h" #include "string.h" int main() {int N,i=0,j,k,flag=0,count[100],count2[100],temp; char s[100][100],c[100][100],end[100][100]; scanf("%d",&N); for(i=0;i<N;i++) {scanf("%s",s[i]); count[i]=1; } for(i=0;i<N;i++) {for(j=0,k=0;s[i][j]!='\0'&&j<50;j++) switch(s[i][j]) { case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': c[i][k++]=s[i][j];break; case 'A':case 'B':case 'C': c[i][k++]='2';break; case 'D':case 'E':case 'F': c[i][k++]='3';break; case 'G':case 'H':case 'I': c[i][k++]='4';break; case 'J':case 'K':case 'L': c[i][k++]='5';break; case 'M':case 'N':case 'O': c[i][k++]='6';break; case 'P':case 'R':case 'S': c[i][k++]='7';break; case 'T':case 'U':case 'V': c[i][k++]='8';break; case 'W':case 'X':case 'Y': c[i][k++]='9';break; default: break; } c[i][k]='\0'; } for(i=1;i<N;i++) for(j=0,k=0;j<i;j++) if(!strcmp(c[i],c[j])) {flag+=1;count[j]+=1;break;} if(!flag) printf("No duplicates.\n"); for(i=0,j=0;i<N;i++) if(count[i]>1) {strcpy(end[k],c[i]); count2[k++]=count[i]; } i=flag; while(i) {for(j=0,temp=0;j<flag;j++) if(strcmp(end[temp],end[j])>0) temp=j; if(count2[temp]>1&&end[temp][0]!='Q') {for(j=0;j<3;j++) {printf("%c",end[temp][j]); end[temp][j]='Q'; } printf("-"); for(;j<7;j++) {printf("%c",end[temp][j]); end[temp][j]='Q'; } printf(" %d\n",count2[temp]); } i--; } system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator