题解 | #密码翻译#
密码翻译
https://www.nowcoder.com/practice/136de4a719954361a8e9e41c8c4ad855
#include<stdio.h> #include<algorithm> #include<string> using namespace std; int main() { char strs[81]; fgets(strs, sizeof(strs), stdin); // 读取一行字符串 // // char转string // string s = strs; int len = 0; for (int i=0; strs[i]!='\0'; i++) { len++; } // 加密 for (int i=0; i<len; i++) { if ((strs[i]>='a' && strs[i]<='y') || (strs[i]>='A' && strs[i]<='Y')) { strs[i] = strs[i]+1; } else if (strs[i]=='z' || strs[i]=='Z') { strs[i] = strs[i] - 25; } else { continue; } } printf("%s", strs); return 0; }