| ||||||||||
| 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题。看在我6点起床的份上#include <iostream.h>
#include <string.h>
#include <stdlib.h>
int compare(const void *a,const void *b)
{
return strcmp((char*)a,(char*)b);
}
void main()
{
int n;
char a[100001][20];
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
int k=0;
for(int j=0;a[i][j]!='\0';j++)
{
if(a[i][j]!='-')
{
a[i][k++]=a[i][j];
}
}
a[i][k]='\0';
for(int y=0;a[i][y];y++){
if(a[i][y]-'A'>=0)
{
if(a[i][y]=='S'||a[i][y]=='V'||a[i][y]=='Y'){a[i][y]=(int)(a[i][y]-'A')/3+1+'0';}
else
{a[i][y]=(int)(a[i][y]-'A')/3+2+'0';}
}
}
}
qsort((void*)a,n,sizeof(a[0]),compare);
int q=0;
for(int m=0;m<n;m++)
{
int u=1;
while(m<n-1&&strcmp(a[m],a[m+1])==0)
{
u++;
m++;
q++;
}
if(u!=1)
{
for(int h=0;h<3;h++)
cout<<a[m][h];
cout<<"-";
for(h=3;a[m][h];h++)
{
cout<<a[m][h];
}
cout<<" "<<u;
cout<<endl;
}
}
if(q==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