| ||||||||||
| 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 | |||||||||
为什么不对啊#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int compare(const void *elem1,const void *elem2)
{
return(strcmp((char*)elem1,(char*)elem2));
}
char map[]="22233344455566677778889999";
char tele[100000][9]={0};
char str[100];
int main()
{
int n,k;cin>>n;
for(int i=0;i<n;i++)
{
cin>>str;
k=0;
for(int j=0;str[j];j++)
{
if(k==3) {tele[i][k++]='-';}
if(str[j]>='A'&&str[j]<='Z')
{tele[i][k++]=map[str[j]-'A'];}
else if(str[j]>='0'&&str[j]<='9')
{tele[i][k++]=str[j];}
else if(str[j]=='-') continue;
}
tele[i][k]='\0';
}
qsort(tele,n,100,compare);
int i,j;
bool asd=true;
for(i=0;i<n;i++)
{
j=i;
while(i<n&&strcmp(tele[i],tele[j])==0) i++;
if(i-j>1)
printf("%s %d\n",tele[j],i-j);
asd=false;
}
if(asd)
cout<<"No duplicates."<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator