| ||||||||||
| 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 | |||||||||
帮忙看看啊 不知错在哪了,就是AC不了#include<stdio.h>
#include <stdlib.h>
#include<string.h>
int n,i,j;
char r[100001][9]={0},s[16],hash[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0};
//void qsort( void *buf, size_t num, size_t size, int (*compare)(const void *, const void *) );
int compare(const void *s1,const void *s2)//返回大于0就交换
{
char *m1=(char*)s1,*m2=(char *)s2;
return strcmp(m1,m2);
}
int main()
{
int len,count;
memset(r,0,sizeof(r));
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",s);
len=strlen(s);
count=0;
for(j=0;j<len;j++)
{
if(count==3)r[i][count++]='-';
if(s[j]=='-')continue;
if(s[j]>='A'&&s[j]<='Z')
{
r[i][count++]=hash[s[j]-'A']+'0';
}
else r[i][count++]=s[j];
}
r[i][count]=0;
}
qsort(r,n,sizeof(char)*9,compare);
count=0;
int targ=0;
for(i=0;i<n;i++)
{
if(strcmp(r[i],r[i+1])==0&&i+1<n){count++;targ=1;}
else
if(count>0)
{
printf("%s %d\n",r[i],count+1);
count=0;
}
}
if(!targ)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