题解 | #密码翻译#
密码翻译
https://www.nowcoder.com/practice/136de4a719954361a8e9e41c8c4ad855
#include <stdio.h> // 计算字符串长度: int Length(char a[]) { int n = 0; for (int i = 0; a[i] != '\0'; i++) { n++; } return n; } int main() { char str[80] = ""; scanf("%[^\n]", str); // 可以输入空格 int len = Length(str); for (int i = 0; i < len; i++) { if ((str[i] >= 65 && str[i] <= 89) || (str[i] >= 97 && str[i] <= 121)) { str[i] += 1; } else if (str[i] == 90) { str[i] = 'A'; } else if (str[i] == 122) { str[i] = 'a'; } } printf("%s\n", str); return 0; }