| ||||||||||
| 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>
using namespace std;
char convert(char c);
int main(void)
{
char ch[100];
int len;
while(cin>>ch)
{
len=strlen(ch);
for(int i=0;i<len;i++)
{
if(i-1>=0)
{
if(ch[i]==ch[i-1])
ch[i-1]=' ';
}
}
for(int j=0;j<len;j++)
for(int k=j+1;k<len;k++)
{
if(convert(ch[j])==convert(ch[k]))
ch[k]=' ';
}
for(int l=0;l<len;l++)
{
if(convert(ch[l])!=' ')
cout<<convert(ch[l]);
if(l==len-1)
cout<<endl;
}
}
return 0;
}
char convert(char c)
{
if(c=='B'||c=='F'||c=='P'||c=='V')
return '1';
if(c=='C'||c=='G'||c=='J'||c=='K'||c=='Q'||c=='S'||c=='X'||c=='Z')
return '2';
if(c=='D'||c=='T')
return '3';
if(c=='L')
return '4';
if(c=='M'||c=='N')
return '5';
if(c=='R')
return '6';
return ' ';
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator