题目:输入一个字符串,将其中大写字母转换为对应小写字母之后的第五个字母,若原始大写字母为V~Z,则转换为对应小写字母的值减21。其他字符变换,输出转换后的字符串。例如,对于字母A,则转换为小写字符f;如形参是字母W,则转换为小写字母b。
样例输入:Axs3mWss
样例输出:fxs3mbss
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
string convert(string s)
{
string::size_type i=0;
string result;
char ch;
for(;i<s.size();i++)
{
if(isupper(s[i]))
{
if(s[i]>='V' && s[i]<='Z')
{
ch=tolower(s[i])+5-26;
result.push_back(ch);
}
else
{
ch=tolower(s[i])+5;
result.push_back(ch);
}
}
else
result.push_back(s[i]);
}
return result;
}
int main()
{
string str;
getline(cin,str);
cout<<convert(str)<<endl;
}