| ||||||||||
| 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求新测试用例,实在是找不出错了,以下是代码#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define MAXN 100000
char s[MAXN][30];
int cmp_string(const void *a, const void *b)
{
return strcmp((char *)a,(char *)b);
}
int main()
{
int n,i,j,flag=0,count=0,m=0,length,found=0;
char str[20];
scanf("%d",&n);
for(i=0;i<n;i++)
{
m=0;
scanf("%s",str);
length=strlen(str);
for(j=0;j<length;j++)
if(str[j]!='-')
if(isdigit(str[j]))s[i][m++]=str[j];
else if(str[j]<'Q')s[i][m++]=(str[j]-'A')/3+'2';
else s[i][m++]=(str[j]-'A'-1)/3+'2';
}
qsort(s,n,sizeof(s[0]),cmp_string);
for(i=0;i<=n;i++)
if((strcmp(s[flag],s[i])==0)&&i<n){count++;continue;}
else
{
if(count>1)
{
for(j=0;j<7;j++)
if(j==2)printf("%c-",s[flag][j]);
else putchar(s[flag][j]);
printf(" %d\n",count);
found=1;
}
count=1;flag=i;
}
if(!found)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