| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
过了,挺开心的,都自己写的,map映射# include <cstdio>
# include <iostream>
# include <string>
# include <cstring>
# include <map>
using namespace std;
map<string, int> m;
map<string, int>::iterator it;
int main(){
int n, i, j, k, cur;
char ch_s[110], s[110];
scanf("%d", &n);
for(i=1; i<=n; i++){
scanf("%s", s);
cur=0;
for(k=0; k<=strlen(s)-1; k++){
if(isdigit(s[k])){
ch_s[cur++]=s[k];
}
else if(isalpha(s[k])){
switch(s[k]){
case'A': case'B': case'C':
ch_s[cur++]='2';break;
case'D': case'E': case'F':
ch_s[cur++]='3';break;
case'G': case'H': case'I':
ch_s[cur++]='4';break;
case'J': case'K': case'L':
ch_s[cur++]='5';break;
case'M': case'N': case'O':
ch_s[cur++]='6';break;
case'P': case'R': case'S':
ch_s[cur++]='7';break;
case'T': case'U': case'V':
ch_s[cur++]='8';break;
case'W': case'X': case'Y':
ch_s[cur++]='9';break;
}
}
else{
continue;
}
}
ch_s[cur]='\0';
m[ch_s]++;
}
int flage=0;
for(it=m.begin(); it!=m.end(); it++){
if(it->second>1){
flage=1;
string ch_s=(it->first);
for(i=0; i<=2; i++){
printf("%c", ch_s[i]);
}
printf("-");
for(i=3; i<=ch_s.length()-1; i++){
printf("%c", ch_s[i]);
}
printf(" %d\n", it->second);
}
}
if(!flage){
printf("No duplicates.\n");
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator