| ||||||||||
| 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 | |||||||||
1002,为什么wa#include <iostream.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void * a,const void * b)
{
return strcmp( (char *)a,(char *)b);
}
void main()
{
char phone[100001][8];
char tel[101];
int cishu[100001];
int num,i=0,len,j,k=0;
char con[]="22233344455566677778889999";
cin >>num;
for(;i<num;i++)
{
cin >>tel;
cishu[i]=1;
len=strlen(tel);
for(j=0;j<len;j++)
{
if(tel[j]=='-')
{
for(k=j;k<len-1;k++)
tel[k]=tel[k+1];
tel[k]='\0';
len--;
if(tel[j]=='-') j--;
}
if(tel[j]>='A'&&tel[j]<='Y')
tel[j]=con[tel[j]-'A'];
}
strcpy(phone[i],tel);
}
qsort(phone,num,sizeof(phone[0]),cmp);
i=0;
for(j=0;j<num;)
{
i=j+1;
for(;i<num&&strcmp(phone[i],phone[j])==0;i++)
{
cishu[j]++;
cishu[i]=-100001;
}
if(i>j+1&&cishu[j]>1)
{
k++;
for(int x=0;x<7;x++)
{
if(x==3)
cout <<'-';
cout <<phone[j][x];
}
cout <<' '<<cishu[j]<<endl;
}
j=i;
}
if(k==0) cout <<"No duplicates."<<endl;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator