Description

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with
a hyphen between the third and fourth digits (e.g. 888-1200). The
keypad of a phone supplies the mapping of letters to numbers, as
follows:

A, B, and C map to 2

D, E, and F map to 3

G, H, and I map to 4

J, K, and L map to 5

M, N, and O map to 6

P, R, and S map to 7

T, U, and V map to 8

W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be
added and removed as necessary. The standard form of TUT-GLOP is
888-4567, the standard form of 310-GINO is 310-4466, and the standard
form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from
local businesses. As part of the quality control process you want to
check that no two (or more) businesses in the directory have the same
telephone number.

Input

The
input will consist of one case. The first line of the input specifies
the number of telephone numbers in the directory (up to 100,000) as a
positive integer alone on the line. The remaining lines list the
telephone numbers in the directory, with each number alone on a line.
Each telephone number consists of a string composed of decimal digits,
uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the
characters in the string will be digits or letters.

Output

Generate
a line of output for each telephone number that appears more than once
in any form. The line should give the telephone number in standard form,
followed by a space, followed by the number of times the telephone
number appears in the directory. Arrange the output lines by telephone
number in ascending lexicographical order. If there are no duplicates in
the input print the line:

No duplicates.

Sample Input

12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

Sample Output

310-1010 2
487-3279 4
888-4567 3
 /*
问题 输入包含大写字母、-、数字的字符串,将其中的大写字母转换成对应的数字,即标准化后,将出现超过2次的号码标准的形式
按字典序输出。
解题思路 先将字符串存储,将其转化为标准形式存入map映照容器中,其中插入键值和映照数据是注意pair的使用,条件输出即可。
*/
#include<cstdio>
#include<string>
#include<cctype>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std; struct phoneNumber{
string num;
int cou;
}phoList[]; int phocou; string conver(char *str);
char aton(char a);
void check(string str); map<string,int> m; int main()
{
int n,i;
string temp;
char str[]; while(scanf("%d",&n) != EOF){
for(i=;i<n;i++){
scanf("%s",str);
temp=conver(str);
check(temp);
}
/*for(i=0;i<phocou;i++){
cout<<phoList[i].num<<' '<<phoList[i].cou<<endl;
}*/ int flag=;
map<string,int>::iterator it;
for(it=m.begin();it != m.end(); it++){
if(it->second > ){
flag=;
cout<<it->first<<' '<<it->second<<endl;
}
}
if(!flag)
cout<<"No duplicates.\n";
}
return ;
} void check(string str)
{
map<string,int>::iterator it;
it=m.find(str);
if(it == m.end())
m.insert( pair<string,int>(str,) );
else
it->second++;
} string conver(char *str)
{
int len=strlen(str),i;
string sum;
for(i=;i<len;i++){
if(isalpha(str[i])){
sum = sum + aton(str[i]);
}
else if(isdigit(str[i])){
sum = sum + str[i];
}
}
string::iterator it=sum.begin();
sum.insert(it + ,'-');
//cout<<sum<<endl;
return sum;
} char aton(char a)
{
if(a == 'A' || a == 'B' || a == 'C')
return '';
if(a == 'D' || a == 'E' || a == 'F')
return '';
if(a == 'G' || a == 'H' || a == 'I')
return '';
if(a == 'J' || a == 'K' || a == 'L')
return '';
if(a == 'M' || a == 'N' || a == 'O')
return '';
if(a == 'P' || a == 'R' || a == 'S')
return '';
if(a == 'T' || a == 'U' || a == 'V')
return '';
if(a == 'W' || a == 'X' || a == 'Y')
return '';
}

POJ 1002 487-3279(map映照容器的使用)的更多相关文章

  1. C++ map 映照容器

    map映照容器的元素数据是一个键值和一个映照数据组成的,键值与映照数据之间具有一一映照的关系. map映照容器的数据结构是采用红黑树来实现的,插入键值的元素不允许重复,比较函数只对元素的键值进行比较, ...

  2. map映照容器的使用

    map映照容器可以实现各种不同类型数据的对应关系,有着类似学号表的功能. 今天在做并查集的训练时,就用上了map映照容器. 题目就不上了,直接讲一下用法.顺便说一下,实现过程是在C++的条件下. #i ...

  3. map映照容器

    //map映照容器是由一个键值和一个映照数据组成的,键值与映照数据之间具有一一映照的关系 //map映照容器的键值不允许重复 ,比较函数值对元素 //的键值进行比较,元素的各项数据可通过键值检索出来 ...

  4. 统计频率(map映照容器的使用)

    问题描述  AOA非常喜欢阅读莎士比亚的诗,莎士比亚的诗中有种无形的魅力吸引着他!他认为莎士比亚的诗中之所以些的如此传神,应该是他的构词非常好!所以AOA想知道,在莎士比亚的书中,每个单词出现的频率各 ...

  5. zoj 2104 Let the Balloon Rise(map映照容器的应用)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2104 题目描述: Contest time again! Ho ...

  6. zoj 1109 Language of FatMouse(map映照容器的典型应用)

    题目连接: acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1109 题目描述: We all know that FatMouse doe ...

  7. map映照容器(常用的使用方法总结)

    map映照容器的数据元素是由一个键值和一个映照数据组成的,键值和映照数据之间具有一一对应的关系.map与set集合容器一样,不允许插入的元素的键值重复. /*关于C++STL中map映照容器的学习,看 ...

  8. C++STL之map映照容器

    map映照容器 map映照容器的元素数据是由一个键值和一个映照数据组成的, 键值与映照数据之间具有一一映照关系. map映照容器的数据结构也是采用红黑树来实现的, 插入元素的键值不允许重复, 比较函数 ...

  9. POJ 1002 487-3279 (map )

    title: 487-3279 map POJ1002 tags: [map] 题目链接 Description Businesses like to have memorable telephone ...

随机推荐

  1. vdscode连接git服务器(以码云为例)

    准备工作:先下载并安装git客户端 1.在码云或者github上新建项目,获得新建项目的地址,得到一个类似:https://gitee.com/zhangshitongsky/vueTest.git ...

  2. Nvu

    在Jennifer Niederst Robbins的书<Learning Web design>(密码:v9i1)推荐软件Nvu 界面: Nvu tips:

  3. Android-Java-synchronized同步代码块的使用场景

    synchronized同步代码块的使用场景 (满足以下两种条件,就要考虑使用synchronize同步代码块了) 1.被synchronized同步代码块{同步的代码},是被多次异步调用,什么叫多次 ...

  4. 关于使用java自动发邮件--找不到smtphost

    今天解决报的第二个异常:Unknown SMTP host: smtp.qq.com;在找了网上的一些资料后,有看到是因为使用了代理服务器,所以无法访问.我试着用了telnet去访问,确实不行.最近都 ...

  5. iTerm2连接远程-中文乱码问题

    现象 mac 上用是iterm2终端, Shell 环境是zsh. ssh 到Linux 服务器上查看一些文件时,中文乱码. 
这种情况一般是终端和服务器的字符集不匹配,MacOSX下默认的是utf8 ...

  6. SSO集成方案[随笔]

    看这个方案之前,先说明下为什么要加入SSO,以防对大家产生不好的影响.我们产品使用传统winform+db服务+Db存储方式开发,一群老菜帮子开发,以传统的datatble做数据传递,很多年了未有变化 ...

  7. 【编程之外】从《海贼王》的视角走进BAT的世界

    写在前面的话: 1.从写第一篇博客起到现在篇“纯”技术博客,所以呢-,就想写点不一样的东西,所以就有了这篇文章了 2.本文纯属瞎写,不代表任何第三方的观点.仅仅是出于我对于博客园和那部热血动漫的热爱. ...

  8. vue.js - 1

    最近开发公司vue前端项目,做一下笔记,偶尔上来查漏补缺 Vue指令之v-bind的三种用法 直接使用指令v-bind 使用简化指令: 在绑定的时候,拼接绑定内容::title="btnTi ...

  9. DES/3DES/AES区别

    公元前400年,古希腊人发明了置换密码.1881年世界上的第一个电话保密专利出现.在第二次世界大战期间,德国军方启用“恩尼格玛”密码机,密码学在战争中起着非常重要的作用. DES 1977年1月,美国 ...

  10. GoLang学习之变量定义和初始化

    变量命名原则 go语言的变量名有字母数字和下划线组成,首字母不能为数字,但是字母不仅仅只限于英文字母,所有的UTF-8字符都是可以的. 变量声明和初始化方式 使用var关键字 var a int = ...