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,数组什么的也试过开很大。但是还是不//行。要死了啊!求救啊。 //另外就是有个问题如果输入是0-1,那么这个电话翻译出来是000-0001吧? //就算这样,我也写了处理的两个循环//被注释掉。。。还是不能AC。 //希望大家帮忙看看啊。 #include <iostream> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <algorithm> #define L 100001 using namespace std; char s[L][201],s1[201]; int Comp(const void *p1,const void *p2) { return strcmp((char *)p2,(char *)p1); } int main() { int k,t,i,n; scanf("%d",&n); t=0,k=0; //getchar(); while(n--) { k=0; scanf("%s",s1); for(i=0;s1[i]!='\0' && k<8;i) { if(k==3) s[t][k++]='-'; else { if(s1[i]<='Z' && s1[i]>='A') { if(s1[i]=='A' || s1[i]=='B' || s1[i]=='C') s[t][k++]='2'; else if(s1[i]=='D' || s1[i]=='E' || s1[i]=='F') s[t][k++]='3'; else if(s1[i]=='G' || s1[i]=='H' || s1[i]=='I') s[t][k++]='4'; else if(s1[i]=='J' || s1[i]=='K' || s1[i]=='L') s[t][k++]='5'; else if(s1[i]=='M' || s1[i]=='N' || s1[i]=='O') s[t][k++]='6'; else if(s1[i]=='P' || s1[i]=='R' || s1[i]=='S') s[t][k++]='7'; else if(s1[i]=='T' || s1[i]=='U' || s1[i]=='V') s[t][k++]='8'; else if(s1[i]=='W' || s1[i]=='X' || s1[i]=='Y') s[t][k++]='9'; } else if(s1[i]<='9' && s1[i]>='0') s[t][k++]=s1[i]; i++; } } t++; } int j; /*char p[8]; for(i=0;i<t;i++) { int l=strlen(s[i]),x=l; if(l<8) { strcpy(p,s[i]); for(j=7;j>=0;j--) { if(j==3) s[i][j]='-'; else if(x) s[i][j]=p[--x]; else if(x<=0) s[i][j]='0'; } } }*/ qsort(s,L,sizeof(s[0]),Comp); int a[L]; //for(i=0;i<t;i++) // puts(s[i]); for(i=0;i<t;i=j) for(j=i;j<t;j++) { if(strcmp(s[i],s[j])==0) a[i]++; else break; } //因为是从大到小排序的,所以多用了下面的循环输出。(因为不会从小到大排..囧) bool o=0; for(i=t-1;i>=0;i--) if(a[i]>1) { printf("%s %d\n",s[i],a[i]); o=1; } if(!o) printf("No duplicates.\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator