| ||||||||||
| 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;
#define MAX 100000
int a[MAX];
string str[MAX];
char f(char ch)
{
if(ch>='A'&&ch<='Z'){
if(ch=='A'||ch=='B'||ch=='C') return '2';
if(ch=='D'||ch=='E'||ch=='F') return '3';
if(ch=='G'||ch=='H'||ch=='I') return '4';
if(ch=='J'||ch=='K'||ch=='L') return '5';
if(ch=='M'||ch=='N'||ch=='O') return '6';
if(ch=='P'||ch=='R'||ch=='S') return '7';
if(ch=='T'||ch=='U'||ch=='V') return '8';
if(ch=='W'||ch=='X'||ch=='Y') return '9';
}
else return ch;
}
void trans(int n)
{
int i,k,j;
j=0;
for(i=0;i<n;i++) a[i]=1;
while(j<n){
for(k=0,i=0;i<str[j].length()&&((str[j][i]>='A'&&str[j][i]<='Z')||(str[j][i]>='0'&&str[j][i]<='9'));i++)
str[j][k++]=f(str[j][i]);
j++;
}//将字母转换成字符
for(i=0;i<n-1;i++){
for(j=0;j<n;j++){
if(str[i]==str[j]){
a[i]++;
a[j]=0;
}
}
}
for(i=0;i<n&&a[i]>0;i++)
str[i].insert(3,"-");
for(i=0;i<n&&a[i]>0;i++)
cout<<str[i]<<" "<<a[i]<<endl;
}
void main()
{
int i,n,j;
cout<<"Input the num:";
cin>>n;
cout<<"Input "<<n<<" telephone numbers:"<<endl;
for(i=0;i<n;i++) cin>>str[i];
trans(n);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator