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<iostream> #include<cstdlib> char origin[110000][100],transformed[110000][10]; using namespace std; int cmp(const void *a,const void *b) { return strcmp((char*)a,(char*)b); } int main() { void trans(char *p,char *q); int m=0,n; cin >> n; fflush(stdin); while(m<n) { gets(*(origin+m)); trans(*(origin+m),*(transformed+m)); m++; } qsort(transformed,n,sizeof(transformed[0]),cmp); int count=1; int flag=0; char s[10]={}; strcpy(*(transformed+n),s); for(int i=0;i<=n;i++) { if((strcmp(s,*(transformed+i))!=0)) { if(count!=1) { printf("%s %d\n",s,count); } strcpy(s,*(transformed+i)); count=1; } else { flag=1; count++; } } if(flag==0) printf("No duplicates. "); return 0; } void trans(char *p,char *q) { int i=0;int j=0; while(*(p+i)!='\0') { if(j==3) { *(q+j)='-'; j++; } else { switch(*(p+i)) { case'A': case'B': case'C': *(q+j)='2';j++;break; case'D': case'E': case'F':*(q+j)='3';j++;break; case'G': case'H': case'I':*(q+j)='4';j++;break; case'J': case'K': case'L':*(q+j)='5';j++;break; case'M': case'N': case'O':*(q+j)='6';j++;break; case'P': case'R': case'S':*(q+j)='7';j++;break; case'T': case'U': case'V':*(q+j)='8';j++;break; case'W': case'X': case'Y':*(q+j)='9';j++;break; case'0':*(q+j)='0';j++;break; case'1':*(q+j)='1';j++;break; case'2':*(q+j)='2';j++;break; case'3':*(q+j)='3';j++;break; case'4':*(q+j)='4';j++;break; case'5':*(q+j)='5';j++;break; case'6':*(q+j)='6';j++;break; case'7':*(q+j)='7';j++;break; case'8':*(q+j)='8';j++;break; case'9':*(q+j)='9';j++;break; default:break; } i++; } } return; } 写的稍微麻烦了一点,已知的数据都试了,都没问题,不知道哪里错了。。。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator