| ||||||||||
| 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 | |||||||||
Re:郁闷 死了,我 的怎么老说我结果对而输出格式不对阿 高手们给我看看我这段程序问题出在哪,我都快崩溃了!!!!!!!!!!In Reply To:郁闷 死了,我 的怎么老说我结果对而输出格式不对阿 Posted by:lg8t4bysq8 at 2005-11-15 09:32:33 #include<iostream>
using namespace std;
int main()
{
char a[21],t[21];
int b[21],i,j,c;
while(scanf("%s",&a)!=EOF)
{
int l=strlen(a);
for(i=0;i<l;i++)
{
if(a[i]=='B' || a[i]=='F' || a[i]=='P' || a[i]=='V')
{
b[i]=1;
}
else if (a[i]=='C' || a[i]=='G' || a[i]=='J' || a[i]=='K' || a[i]=='Q' || a[i]=='S' || a[i]=='X' || a[i]=='Z')
{
b[i]=2;
}
else if(a[i]=='D' || a[i]=='T')
{
b[i]=3;
}
else if(a[i]=='L')
{
b[i]=4;
}
else if(a[i]=='M' || a[i]=='N')
{
b[i]=5;
}
else if(a[i]=='R')
{
b[i]=6;
}
else
{
b[i]=0;
}
}
c=0;
for(j=0;j<l;j++)
{
if(b[j]==0)
continue;
else
{
if(j-1>=0)
{
if(b[j]==b[j-1])
continue;
}
t[c]=b[j]+48;
c++;
}
}
if(c==0)
continue;
for(int z=0;z<c;z++)
cout<<t[z];
cout<<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