| ||||||||||
| 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>
#include<string>
using namespace std;
int compare(const void *a,const void *b)
{
return (strcmp((char*)a,(char*)b));
}
int main()
{
int N,j=0;
bool have=true;
cin>>N;
char p[100000][8];
for(int i=0;i<N;i++)
{
for(int j=0;j<8;j++)
{
if(j==7)
{
p[i][j]='\0';
break;
}
char x;
cin>>x;
if(x=='-')
{
j--;
continue;
}
else
{
if(x=='A'||x=='B'||x=='C'||x=='2')
p[i][j]='2';
if(x=='D'||x=='E'||x=='F'||x=='3')
p[i][j]='3';
if(x=='G'||x=='H'||x=='I'||x=='4')
p[i][j]='4';
if(x=='J'||x=='K'||x=='L'||x=='5')
p[i][j]='5';
if(x=='M'||x=='N'||x=='O'||x=='6')
p[i][j]='6';
if(x=='P'||x=='R'||x=='S'||x=='7')
p[i][j]='7';
if(x=='T'||x=='U'||x=='V'||x=='8')
p[i][j]='8';
if(x=='W'||x=='X'||x=='Y'||x=='9')
p[i][j]='9';
if(x=='0')
p[i][j]='0';
if(x=='1')
p[i][j]='1';
}
}
}
qsort(p,N,8,compare);
for(int i=0;i<N;i++)
{
j=i+1;
while(j<N&&((int)strcmp(p[i],p[j]))==0)j++;
if(j-i>1)
{
cout<<p[i][0]<<p[i][1]<<p[i][2]<<"-"<<p[i][3]
<<p[i][4]<<p[i][5]<<p[i][6]<<" "<<j-i<<endl;
have=false;
}
}
if(have)
{
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