UVA 755 487--3279
2015-12-21 06:44
253 查看
分析:这个题就有点难度了,设置一个常量数组必不可少,<map>神器记录每个电话号码出现的次数即可。
UVA的题的格式真是让人一醉再醉,一跪再跪,空行,一定要读懂题意,看明白空行所在的位置。。。WA数次,该死的
空行
UVA的题的格式真是让人一醉再醉,一跪再跪,空行,一定要读懂题意,看明白空行所在的位置。。。WA数次,该死的
空行
#include <cstdio> #include <iostream> #include <map> #include <string> #include <cctype> #include <cstring> #include <list> using namespace std; int re[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 main() { map<string,int>cnt; int T,n; string str; cin>>T; getline(cin,str); while(T--) { cnt.clear(); cin>>n; getchar(); while (n--) { string s1; getline(cin,str); for (int j=0;j<str.size();j++) { if (str[j]=='-') continue; else if (str[j]>='A'&&str[j]<='Z') s1+=(re[str[j]-'A']+'0'); else s1+=str[j]; } s1.insert(3,1,'-'); if (!cnt.count(s1)) cnt[s1]=0; cnt[s1]++; } int f=0; map<string,int>::iterator it; for (it=cnt.begin();it!=cnt.end();it++) if (it->second!=1) {cout<<it->first<<" "<<it->second<<endl;f=1;} if (!f) cout<<"No duplicates."<<endl; if (T!=0)cout<<endl; } return 0; }
相关文章推荐
- Leetcode: Shortest Word Distance III
- UVA 299 Train Swapping
- UVA-152 Tree's a Crowd
- RTTI、虚函数和虚基类的实现方式、开销分析及使用指导(虚函数的开销很小,就2次操作而已)
- 开始一个新的地方作为自己技术的心灵园田,新浪微博太伤我心了
- UVA-10420 List of Conquests
- UVA-340 Master-Mind Hints (猜数字)
- Data URI 应用场景小结
- [leetcode] 22. Generate Parentheses 解题报告
- urllib.urlretrieve()
- Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04
- *Reverse Linked List II
- LeetCode - Remove Duplicates from Sorted Array
- C标准库没提供的助手函数:字符串替换
- LeetCode - Reverse Nodes in k-Group
- Leetcode: Shortest Word Distance II
- Android RecyclerView使用详解四
- *Insertion Sort List
- python对文件及文件夹的一些操作
- 二分查找(折半查找)