解题思路:
注意事项:
参考代码:
//C++
#include<iostream>
#include<string>
using namespace std;
string EncryptChar(string str)
{
int len;
len = str.length();
for (int i = 0; i < len; i++)
{
if ((str[i] >= 'A' && str[i] < 'Z') || (str[i] >= 'a'&&str[i] < 'z'))
{
str[i] += 1;
}
else if (str[i] == 'Z')
str[i] = 'a';
else if (str[i] == 'z')
str[i] = 'A';
}
return str;
}
int main()
{
string str;
while(cin >> str)
cout << EncryptChar(str) << endl;
return 0;
}
#python
def EncryptChar(str):
length = len(str)
num = []
for i in range(0,length):
num.append(ord(str[i]))
for i in range(0,length):
if ((num[i] >= 65 and num[i] < 90) or (num[i] >= 97 and num[i] < 122)):
num[i] += 1
elif num[i] == 90:
num[i] = 97
elif num[i] == 122:
num[i] = 65
for i in range(0,length):
num[i] = chr(num[i])
str = ''.join(num)
return str
while True:
str = input()
str1 = EncryptChar(str)
print(str1)
0.0分
1 人评分
陶陶摘苹果 (C语言代码)浏览:1652 |
C语言训练-素数问题 (C语言代码)浏览:1695 |
多输入输出练习1 (C语言代码)浏览:1219 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:790 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:539 |
Minesweeper (C语言描述,蓝桥杯)浏览:1176 |
星期判断机 (C语言代码)浏览:892 |
Hello, world! (C语言代码)浏览:916 |
拆分位数 (C语言代码)浏览:558 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:826 |