请用c++编写下列4个程序 1,将“fiy”译成密码“jpc”。编码规律:将字母a变成字母f,即变成其后的第4个字

2025-12-13 04:26:34
推荐回答(1个)
回答1:

第一个C++程序如下:
#include
#include
using namespace std;

void main()
{
string str;
printf("Input a line:");
cin>>str;

for(string::iterator iter = str.begin(); iter != str.end(); ++iter)
{
if( ((*iter >= 'a' ) && (*iter <= 'z')) ||((*iter >= 'A')&&(*iter <= 'Z')))
{
*iter += 5;

if(((*iter>'z')&&(*iter<='z'+5))|| ((*iter>'Z')&&(*iter<='Z'+5)))
{
*iter -= 26;
}
}
}
cout<}

修改了一下,O了!