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 <algorithm> #include <string> #include <vector> using namespace std; int main() { int i; freopen("in.txt","r",stdin); char array[26]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','0','7','7','8','8','8','9','9','9','0'}; int u; cin>>u; if(u==0||u==1) { cout<<"No duplicates."<<endl; return 0; } string *t=new string[u]; char input[100]; for( i=0;i<u;i++) { cin>>input; int len=strlen(input); for(int j=0;j<len;j++) { if(input[j]!='-') if(input[j]>='A'&&input[j]<='Z') t[i].append(1,array[input[j]-'A']); else t[i].append(1,input[j]); } } vector<string> strArray ; for( i = 0; i<u; i++) strArray.push_back(t[i]); sort(strArray.begin(), strArray.end()); for(i=0;i<u;i++) { t[i]=strArray[i]; cout<<t[i]<<endl; } int flag=0;int num=0;string temp; temp=t[0]; for(i=0; i<u;i++) { if(temp==t[i]) num++; else { if(num==1) { } else { cout<<temp.insert(3,1,'-')<<" "<<num<<endl; flag=1; } temp=t[i]; num=1; } } if(num>=2) { cout<<temp.insert(3,1,'-')<<" "<<num<<endl; return 0; } if(flag==0) 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