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<cstring> using namespace std; const int M=100000; int main() { int i,n,j; char c,num[M][9]; char *pnum[50]; cin>>n; for(i=0;i<n;i++) { j=0; while(cin>>c) { if(c=='-') continue; else if(c>='A'&&c<='C') num[i][j++]='2'; else if(c>='D'&&c<='F') num[i][j++]='3'; else if(c>='G'&&c<='I') num[i][j++]='4'; else if(c>='J'&&c<='L') num[i][j++]='5'; else if(c>='M'&&c<='O') num[i][j++]='6'; else if(c>='P'&&c<='S') num[i][j++]='7'; else if(c>='T'&&c<='V') num[i][j++]='8'; else if(c>='W'&&c<='Y') num[i][j++]='9'; else num[i][j++]=c; if(j==3) num[i][j++]='-'; if(j>7) break; } pnum[i]=num[i]; num[i][j]='\0'; } for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(strcmp(pnum[i],pnum[j])>0) swap(pnum[i],pnum[j]); int sum,k,flag=1; for(i=0;i<n;i++) { k=i; sum=0; for(j=k+1;j<n;j++) { if(strcmp(pnum[i],pnum[j])==0) { sum++; flag=0; } else {i=j-1;break;} } if(sum) { if(k==0) { for(j=0;j<9;j++) cout<<pnum[k][j]; cout<<sum+1<<endl; } else if(strcmp(pnum[k],pnum[k-1])!=0) { for(j=0;j<9;j++) cout<<pnum[k][j]; cout<<sum+1<<endl; } } } if(flag) cout<<"No duplicates."<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator