#include <iostream> #include <map> #include <string> #include <cstring> #include <cstdio> using namespace std; map<string,int> my; char a[30]="2223334445556667777888999"; int main(int argc, char *argv[]) { int n,i,j,sum; char ss[1005],s[1005]; while(scanf("%d",&n)!=EOF) { my.clear(); sum=0; while(n--) { scanf("%s",ss); for(j=i=0;i<strlen(ss);i++) { if(j==3) s[j++]='-'; if(ss[i]>='A'&&ss[i]<='Z') s[j++]=a[ss[i]-'A']; else if(ss[i]!='-') s[j++]=ss[i]; } s[j]=0; my[s]++; } map<string,int> ::iterator it; for(it=my.begin();it!=my.end();it++) { if((*it).second>1) {cout<<(*it).first; printf(" %d ",(*it).second); sum++;} } if(!sum) printf("No duplicates. "); } return 0; }
#include <iostream>
#include <map>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
map<string,int> my;
char a[30]="2223334445556667777888999";
int main(int argc, char *argv[])
{
int n,i,j,sum; char ss[1005],s[1005];
while(scanf("%d",&n)!=EOF)
{
my.clear(); sum=0;
while(n--)
{
scanf("%s",ss);
for(j=i=0;i<strlen(ss);i++)
{
if(j==3) s[j++]='-';
if(ss[i]>='A'&&ss[i]<='Z') s[j++]=a[ss[i]-'A'];
else if(ss[i]!='-') s[j++]=ss[i];
}
s[j]=0;
my[s]++;
}
map<string,int> ::iterator it;
for(it=my.begin();it!=my.end();it++)
{
if((*it).second>1) {cout<<(*it).first; printf(" %d
",(*it).second); sum++;}
}
if(!sum) printf("No duplicates.
");
}
return 0;
}