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 |
ac代码水过供借鉴#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { string str[100002]; char mm []= {'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','8','8','8','9','9','9'}; char s[60]; char cmp1[7],cmp2[7]; char s1[60]; int n,i,j,k; cin>>n; for(i = 0; i< n;i++) { cin>>s; k = 0; for(j = 0;j<strlen(s);j++) { if(s[j]>='A'&&s[j]<='P') { s1[k] = mm[s[j]-'A']; k++; } else if(s[j]>'Q'&&s[j]<='Y') { s1[k] = mm[s[j]-'A'-1]; k++; } else if(s[j]>='0'&&s[j]<='9') { s1[k] = s[j]; k++; } } s1[k]='\0'; str[i]=s1; } sort(str,str+n); int count = 0,flag = -1; int h; i=0; while(i<n) { h = 1; while(1) { for(j = 0;j<7;j++) if(str[i][j]-str[i+1][j]!=0) break; if(j==7) { h++; i++; flag = 0; } else { i++; break; } } if(h!=1) { cout<<str[i-1][0]<<str[i-1][1]<<str[i-1][2]<<"-"<<str[i-1][3]<<str[i-1][4]<<str[i-1][5]<<str[i-1][6]<<" "<<h<<endl; } } if(flag==-1) cout<<"No duplicates."<<endl; // system("pause"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator