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. telerik:RadGrid 分组自动展开

    在 MasterTableView 加上 GroupsDefaultExpanded = " true " 即可 自动展开分组下面的子项

  2. Asp.Net MVC EF之二:原生EF插入,更新数据的正确方法

    引言 EF是相对与Dapper.NHibernate官方首推的ORM框架,其在开发过程中的方便,快捷毋庸置疑的,但由于EF本身的一些缓存机制.跟踪机制,所以在使用时有些地方需要特别注意. 下面我将自己 ...

  3. C#开发邮件收发(同步)

    发邮件界面: 收邮件界面: 先分析邮件发送类 邮件发送类使用smtp协议,这里以QQ邮箱为例 using System; using System.Collections.Generic; using ...

  4. Linux系统Bash的常用功能(9)

    了解了基本的Linux文件文件系统的概念后,我们将更深入的了解一下Linux的其他方面的内容,那就是我们所使用的用户接口,也就是大家常听到的 『Shell』 ,『这个shell并不是黑客反弹的shel ...

  5. Dubbo实现原理之基于SPI思想实现Dubbo内核

    dubbo中SPI接口的定义如下: @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public ...

  6. Redis中的批量操作Pipeline

    大多数情况下,我们都会通过请求-相应机制去操作redis.只用这种模式的一般的步骤是,先获得jedis实例,然后通过jedis的get/put方法与redis交互.由于redis是单线程的,下一次请求 ...

  7. css居中小结

    从css入门就开始接触,无所不在的,一直备受争议的居中问题. css居中分为水平居中和垂直居中,水平居中方式也较为常见和统一,垂直居中的方法就千奇百怪了. 博客原文地址:Claiyre的个人博客 ht ...

  8. 设计模式《JAVA与模式》之解释器模式

    在阎宏博士的<JAVA与模式>一书中开头是这样描述解释器(Interpreter)模式的: 解释器模式是类的行为模式.给定一个语言之后,解释器模式可以定义出其文法的一种表示,并同时提供一个 ...

  9. RegexHelper.js

    var Validator = { VerityLib: { //验证字符串非空 IsNotEmpty: function (input) { if (input != '') { return tr ...

  10. android电量优化 总结

    移动设备电池容量小,耗电较快(基本一天一充) ,故我们在应用开发使用相关组件和方法时候必须考虑耗电情况: 一   通过Battery Historian查看手机的耗电状况, 可以知道Android的在 ...