| ||||||||||
| 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 | |||||||||
!!!!好心的大牛帮帮忙,数据过了,为什么WA! 谢谢啦!!!!#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int compare(const void *p1,const void *p2)
{
return (strcmp( (char*)p1,(char*)p2 ));
}
char map[] = "22233344455566677778889999";
char str[80],tel[100001][9];
void stand( int n )
{
int j,k;
j = k = -1;
while(k<8)
{
j++;
if(str[j] == '-')
continue;
k++;
if(k == 3)
{
tel[n][k] = '-';
k++;
}
if( str[j]>='A'&&str[j]<='Z')
{
tel[n][k] = map[str[j]-'A'];
continue;
};
tel[n][k] = str[j];
}
tel[n][k] = '\0';
return;
}
int main()
{
int n,i,j;
bool pd;
cin>>n;
for( i = 0 ; i < n ; i++ )
{
scanf("%s",str);
stand(i);
}
qsort(tel,n,9,compare);
pd = true;
i = 0;
while(i<n)
{
j=i;
i++;
while(i<n && strcmp(tel[i],tel[j]) == 0)
i++;
if(i-j>1)
{
cout<<tel[j]<<' '<<i-j<<endl;
pd = false;
}
}
if(pd)
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