| ||||||||||
| 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 <string>
using namespace std;
char array[26]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'};
int main()
{
int i,j,k,n,length,judge,count=0,duplicate=0,num[100];
char ch[30],temp[30],record[100][30];
for(i=0;i<10;i++)
{
ch[i]=NULL;
temp[i]=NULL;
}
for(i=0;i<100;i++)
{
num[i]=0;
for(j=0;j<10;j++)
record[i][j]=NULL;
}
cin>>n;
getchar();
for(i=0;i<n;i++)
{
k=0;
judge=0;
gets(ch);
length=strlen(ch);
//cout<<length<<" "<<ch<<endl;
for(j=0;j<length;j++)
{
//cout<<ch[j]<<endl;
if(k==3)
{
temp[k]='-';
// cout<<temp[k]<<endl;
k++;
}
if(ch[j]!='-')
{
if(ch[j]<='z' && ch[j]>='a')
{
temp[k]=array[ch[j]-'a'];
// cout<<temp[k]<<endl;
k++;
}
else if(ch[j]<='Z' && ch[j]>='A')
{
//cout<<"啊"<<array[ch[j]-'A']<<endl;
temp[k]=array[ch[j]-'A'];
// temp[k]='1';
// cout<<temp[k]<<endl;
k++;
}
else
{
temp[k]=ch[j];
// cout<<temp[k]<<endl;
k++;
}
}
}
temp[k]='\0';
//cout<<k<<" "<<temp<<endl;
for(j=0;j<count;j++)
{
if(strcmp(record[j],temp)==0)
{
num[j]++;
judge=1;
duplicate=1;
}
}
if(judge==0)
{
strcpy(record[count],temp);
num[count]++;
count++;
}
}
for(i=0;i<count;i++)
for(j=i+1;j<count;j++)
{
if(strcmp(record[i],record[j])>0)
{
strcpy(temp,record[i]);
strcpy(record[i],record[j]);
strcpy(record[j],temp);
}
}
if(duplicate==1)
{
for(i=0;i<count;i++)
{
if(num[i]>1)
{
length=strlen(record[i]);
if(length<=8)
cout<<record[i]<<" "<<num[i]<<endl;
else
{
for(j=0;j<=7;j++)
cout<<record[i][j];
cout<<" "<<num[i]<<endl;
}
}
}
}
else 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