| ||||||||||
| 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<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
int cmp(const void*a,const void*b)
{
char*aa=(char*)a;
char*bb=(char*)b;
return strcmp(aa,bb);
}
int main()
{
int n;
char m[]="222333444555666777888999";
char a[100009][9],b[100];
scanf("%d",&n);
fflush(stdin);
for(int i=0;i<n;i++)
{
gets(b);
fflush(stdin);
for(int k=0,j=0;k<=8;j++)
{
if(b[j]=='-') continue;
else if(b[j]>='A'&&b[j]<='P') {a[i][k]=m[b[j]-'A'];}
else if(b[j]>='R'&&b[j]<='Y') {a[i][k]=m[(b[j]-'A')-1];}
else if(b[j]>='0'&&b[j]<='9') {a[i][k]=b[j];}
if(k==2) {a[i][3]='-';k++;}
k++;
}
}
qsort(a,n,9,cmp);
int count=1;
int chongfu=0;
for(int i=0;i<n;i++)
{
if(strcmp(a[i],a[i+1])==0)
{
count++;chongfu=1;
}
else if(count>1)
{
printf("%s %d\n",a[i],count);
count=1;
}
}
if(chongfu==0) 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