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 |
sample过了,但提交时wa,大家能替我看看吗?#include<iostream.h> #include<string.h> int main(){ int n,k,i,j; cin>> n; cin.ignore(); char **input = new char *[n]; char **a = new char *[n]; int * count = new int [n]; int * asd = new int [n]; for(i = 0;i < n;i ++){ input[i]=new char [20]; a[i]=new char [7]; } for(i = 0; i < n; i ++) cin.getline(input[i],20); for(i = 0;i < n; i ++){ k = 0; for (j = 0; j < 20; j ++){ if(input[i][j]=='A'||input[i][j]=='B'||input[i][j]=='C') { a[i][k]='2'; k++; } if(input[i][j]=='D'||input[i][j]=='E'||input[i][j]=='F') { a[i][k]='3'; k++; } if(input[i][j]=='G'||input[i][j]=='H'||input[i][j]=='I') { a[i][k]='4'; k++; } if(input[i][j]=='J'||input[i][j]=='K'||input[i][j]=='L') { a[i][k]='5'; k++; } if(input[i][j]=='M'||input[i][j]=='N'||input[i][j]=='O') { a[i][k]='6'; k++; } if(input[i][j]=='P'||input[i][j]=='R'||input[i][j]=='S') { a[i][k]='7'; k++; } if(input[i][j]=='T'||input[i][j]=='U'||input[i][j]=='V') { a[i][k]='8'; k++; } if(input[i][j]=='W'||input[i][j]=='X'||input[i][j]=='Y') { a[i][k]='9'; k++; } if(input[i][j]=='0') { a[i][k]='0'; k++; } if(input[i][j]=='1') { a[i][k]='1'; k++; } if(input[i][j]=='2') { a[i][k]='2'; k++; } if(input[i][j]=='3') { a[i][k]='3'; k++; } if(input[i][j]=='4') { a[i][k]='4'; k++; } if(input[i][j]=='5') { a[i][k]='5'; k++; } if(input[i][j]=='6') { a[i][k]='6'; k++; } if(input[i][j]=='7') { a[i][k]='7'; k++; } if(input[i][j]=='8') { a[i][k]='8'; k++; } if(input[i][j]=='9') { a[i][k]='9'; k++; } } } for(i = 0; i < n; i ++){ count[i]=1; asd[i]=1; } for(i = 0; i < n; i ++){ if(asd[i]==0) continue; for (j = i+1; j < n; j ++){ if(strcmp(a[j],a[i])==0){ count[i]++; asd[j]=0; } } } char temp[7]; int p,temp2; for(i = 0;i < n - 1; i ++){ p = i; for (j = i+1; j < n; j ++){ if(strcmp(a[p],a[j])==1) p=j; } if(p!=i){ for(int v=0;v<7;v++){ temp[v]=a[p][v]; a[p][v]=a[i][v]; a[i][v]=temp[v]; } temp2=count[p]; count[p]=count[i]; count[i]=temp2; } } int dfg=n; for(i = 0; i < n; i ++){ if(count[i]>=2) cout<<a[i][0]<<a[i][1]<<a[i][2]<<"-"<<a[i][3]<<a[i][4]<<a[i][5]<<a[i][6]<<" "<<count[i]<<endl; else dfg--; } if(dfg==0) cout<<"No duplicates."<<endl; delete []*input; delete []*a; delete []count; delete []asd; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator