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 |
哪位牛人请帮看一下,c++总是wa,谢谢了#include<iostream> #include<string> using namespace std; int comp(const void *a,const void *b) { return (strcmp((char *)a,(char *)b)); } void fun(char *al) { if (*al=='A'||*al=='B'||*al=='C') *al='2'; else if (*al=='D'||*al=='E'||*al=='F') *al='3'; else if (*al=='G'||*al=='H'||*al=='I') *al='4'; else if (*al=='J'||*al=='K'||*al=='L') *al='5'; else if (*al=='M'||*al=='N'||*al=='O') *al='6'; else if (*al=='P'||*al=='R'||*al=='S') *al='7'; else if (*al=='T'||*al=='U'||*al=='V') *al='8'; else if (*al=='W'||*al=='X'||*al=='Y') *al='9'; } void output(char *s) { int i; for(i=0;i<3;i++) { cout<<s[i]; } cout<<"-"; for(i=3;i<7;i++) { cout<<s[i]; } } int funfun(char *s,char *m) { int k=0; for(int i=0;i<7;i++) if(s[i]!=m[i]) k=1; return(k); } int main() { char a[100000][7]={0}; char s[7]={0}; char k[7]={0}; int i,j; char c; int n; cin>>n; int num; int mark=0; for(num=0;num<n;num++) { for(i=0;i<7;i++) { cin>>c; while(c=='-')cin>>c; s[i]=c; } for(j=0;j<7;j++) { fun(&s[j]); a[num][j]=s[j]; } } qsort(a,n,sizeof(char)*7,comp); for(i=0;i<7;i++) s[i]=a[0][i]; num=0; int lllllll=0; for(j=0;j<n;j++) { for(i=0;i<7;i++) k[i]=a[j][i]; if(funfun(s,k)==0) ++num; else { if(num!=1) { output(s); cout<<" "<<num; mark=1; if(j!=n-1) cout<<endl; } else{} num=1; for(i=0;i<7;i++) s[i]=k[i]; } } if(mark==0) cout<<"No duplicates. "; else{} return(0); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator