poj 1002
2012-03-14 15:50
218 查看
问题:487-3297 链接:http://poj.org/problem?id=1002
#include<iostream>
#include<map>#include<algorithm>#include<cctype>#include<string>using namespace std;map<string,int> tell;string change(string str){string sub="";for(int i=0;i<str.length();i++){if(isdigit(str[i])){sub.append(1,str[i]);}else{if(str[i]=='A'||str[i]=='B'||str[i]=='C'){sub.append(1,'2');}if(str[i]=='D'||str[i]=='E'||str[i]=='F'){sub.append(1,'3');}if(str[i]=='G'||str[i]=='H'||str[i]=='I'){sub.append(1,'4');}if(str[i]=='J'||str[i]=='K'||str[i]=='L'){sub.append(1,'5');}if(str[i]=='M'||str[i]=='N'||str[i]=='O'){sub.append(1,'6');}if(str[i]=='P'||str[i]=='R'||str[i]=='S'){sub.append(1,'7');}if(str[i]=='T'||str[i]=='U'||str[i]=='V'){sub.append(1,'8');}if(str[i]=='W'||str[i]=='X'||str[i]=='Y'){sub.append(1,'9');}}}str ="";str = str.append(sub.substr(0,3)).append(1,'-').append(sub.substr(3,4));return str;}int main(){int count = 0;string str;cin>>count;while(count--){cin>>str;str = change(str);++tell[str];}map<string,int>::iterator it = tell.begin();int num = 0;while(it!=tell.end()){if((it->second)>1){cout<<it->first<<" "<<it->second<<endl;num++;}it++;}if(num == 0)cout<<"No duplicates."<<endl;return 0;}
相关文章推荐
- POJ 1002
- POJ 1002
- 一个字典树问题--电话号码转化问题(POJ 1002 487-3279)
- poj 1002
- POJ 1002 487-3279 Trie解读
- poj1002 字符串
- POJ_1002 487-3279
- poj1002的java实现
- POJ1002 487-3279
- POJ 1002 487-3279
- POJ1002 487-3279
- POJ——1002 487-3279
- poj1002
- C++——字符串例题——487-3279(POJ1002)
- 【poj1002】487-3279
- 【POJ 1002】487-3279
- poj1002
- poj 1002
- POJ 1002 487-3279(map)
- poj 1002 487-3279