问题及代码:
/*
*All rights reserved.
*文件名称:test.cpp
*作 者:尚 月
*完成日期:2015年 04 月 21 日
*版本号:V1.0
*
*问题描述:要将"China"译成密码,译码规律是:用原来字母后面的第4个字母代替原来的字母.例如,字母"A"后面第4个字母是"E"."E"代替"A"。因此,"China"应译为"Glmre"。请编一程序,用赋初值的方法使cl、c2、c3、c4、c5五个变量的值分别为,’C’、’h’、’i’、’n’、’a’,经过运算,使c1、c2、c3、c4、c5分别变为’G’、’l’、’m’、’r’、’e’,并输出。
*输入描述:China
*程序输出:加密后的China
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int j=0;
char str[50];
gets(str);
while (str[j]!='\0')
{
if ((str[j]>='A')&&(str[j]<='V'))
str[j]+=4;
else if((str[j]>='a')&&(str[j]<='v'))
str[j]+=4;