#include<iostream>
#include<string>
using namespace std;
int main()
{
char ch1[11],ch2[201],ch3[201];
int i;
while(gets(ch1))
{
if(ch1=="ENDOFINPUT")break;
cin.getline(ch2,201);
i=0;
while(ch2[i]!='\0')
{
if(ch2[i]<'A'||ch2[i]>'Z')
{
ch3[i]=ch2[i];
i++;
continue;
}
else
{
if(ch2[i]>='F')
ch3[i]=ch2[i]-5;
else
ch3[i]='Z'+(ch2[i]-'A')-4;
i++;
}
}
ch3[i]='\0';
cout<<ch3<<endl;
gets(ch1);
}
return 0;
}
<iostream>
#include<string>
using namespace std;
int main()
{
char ch1[11],ch2[201],ch3[201];
int i;
while(gets(ch1))
{
if(ch1=="ENDOFINPUT")break;
cin.getline(ch2,201);
i=0;
while(ch2[i]!='\0')
{
if(ch2[i]<'A'||ch2[i]>'Z')
{
ch3[i]=ch2[i];
i++;
continue;
}
else
{
if(ch2[i]>='F')
ch3[i]=ch2[i]-5;
else
ch3[i]='Z'+(ch2[i]-'A')-4;
i++;
}
}
ch3[i]='\0';
cout<<ch3<<endl;
gets(ch1);
}
return 0;
}
北大OJ1298
最新推荐文章于 2021-01-27 22:35:56 发布