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 |
用mapG++过不了会T,C++能过#include<iostream> #include<map> #include<string> #include<stdio.h> using namespace std; int main() { map<string,int>resultmap; int n; char num[] = "22233344455566670778889990"; string s; string s1; scanf("%d",&n); while(n>0) { cin >> s; int len = s.length(); int j = 0; s1.clear(); for(int i = 0; i<len;i++) { if(s[i] == '-') { continue; } else if(isdigit(s[i])) { s1 +=s[i]; } else { s1+=num[s[i]-'A']; } } s1.insert(3,1,'-'); resultmap[s1]++; n--; } bool flag = false; for(map<string,int>::const_iterator i = resultmap.begin();i != resultmap.end();i++) { if(i->second > 1) { string s2 = i->first; int nnn = i->second; printf("%s %d\n",s2.c_str(),nnn); flag = true; } } if(!flag) { printf("No duplicates.\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator