| ||||||||||
| 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 | |||||||||
请大家看看颈瓶在哪?老是超时#include <iostream>
#include <algorithm>
using namespace std;
const char table[]={"22233344455566677778889999"};
struct sm{char i[9];int c;sm(){c=0;}};
void GetI(char* s,char* o)
{
int r=0;
while(*s!='\0'){
if(r==3)o[r++]='-';
{
if(*s>='A'&&*s<='Z'){
o[r++]=table[*s-'A'];
}
else if(*s>='0'&&*s<='9'){
o[r++]=*s;
}
}
++s;
}
}
bool cmp(sm a,sm b){return strcmp(a.i ,b.i)<0;}
int main()
{
int n,cur=0;bool val=true;
cin>>n;
sm num[100000];//=new sm[n];
int z; for(z=0;z<n;z+=1)
{
char str[64],aa[9];aa[8]=0;
cin>>str;
GetI(str,aa);
int i;for(i=0;i<cur;i++)
{
if(strcmp(num[i].i,aa)==0)
{
num[i].c++;
break;
}
}
if(i==cur)
{
strcpy(num[i].i,aa);num[i].c=1;
cur++;
}
}
sort(num,num+cur,cmp);
for(z=0;z<cur;z++)
{
if(num[z].c >1)
{
val=false;
cout<<num[z].i<<" "<<num[z].c<<endl;
}
}
if(val)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