参考资料:http://bbs.csdn.net/topics/390656680 getline
//
// main.cpp
// poj_test2
//
// Created by 超好吃的混糖饼 on 16/4/4.
// Copyright © 2016年 超好吃的混糖饼. All rights reserved.
//
#include <iostream>
#include "string"
#include <typeinfo>
#include <map>
using namespace std;
int fun(char a){
switch(a)
{
case 'A':
case 'B':
case 'C': return '2';
case 'D':
case 'E':
case 'F': return '3';
case 'G':
case 'H':
case 'I': return '4';
case 'J':
case 'K':
case 'L': return '5';
case 'M':
case 'N':
case 'O': return '6';
case 'P':
case 'R':
case 'S': return '7';
case 'T':
case 'U':
case 'V': return '8';
case 'W':
case 'X':
case 'Y': return '9';
default: return a;
}
}
int main(){
int n, i, j;
string str;
string ans = "";
map<string, int> myMap;
map<string, int>::iterator start, end;
bool flag = true;
cin>>n;
getchar();
for(i = 0; i < n; i++){
getline(cin, str);
for(j = 0; j < strlen(str.c_str()); j++){
if ( (str[j] >= 'A' &&str[j] <= 'Z') || (str[j] >= '0' && str[j] <= '9') ) {
ans += fun(str[j]);
}
}
myMap[ans] += 1;
ans = "";
}
for(start = myMap.begin(), end = myMap.end(); start != end; start++){
if (start->second != 1) {
flag = false;
for (i = 0; i < 7; i++) {
cout<<start->first[i];
if (i==2) {
cout<<'-';
}
}
cout<<" "<<start->second<<endl;
}
}
if (flag) {
printf("No duplicates.");
}
return 0;
}