题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/ff99c43dd07f4e95a8f2f5448da3772a
#include "cstdio" #include "strings.h" #include "string" #include "string.h" using namespace std; int main() { char buf[201]; while (scanf("%s", buf) != EOF) { if (0 == strcmp(buf, "ENDOFINPUT")) { break; } if (0 == strcmp(buf, "START")) { int x = getchar(); // printf("x=%d\n", x); fgets(buf, sizeof buf, stdin); string str = buf; // A65 Z90 for (int i = 0; i < str.length(); ++i) { if (str[i] >= 'F' && str[i] <= 'Z') { str[i] = str[i] - 5; } else if (str[i] <= 'E' && str[i] >= 'A') { str[i] = str[i] + 21; } } printf("%s", str.c_str()); } fgets(buf, sizeof buf, stdin); if (0 == strcmp(buf, "END")) { continue; } } return 0; }