题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/ff99c43dd07f4e95a8f2f5448da3772a
#include <stdlib.h> #include <stdio.h> #include <string.h> #define len 2000 char resolve(char c){ if(c>='A'&&c<='Z'){ return (c-'A'-5+26)%26+'A'; } return c; } int main(){ char str[len]; while(fgets(str,sizeof(str),stdin)){ if(strcmp(str,"ENDOFINPUT\n")==0){ break; } fgets(str,sizeof(str),stdin); int n = strlen(str)-1; for(int i = 0;i<n;i++){ printf("%c",resolve(str[i])); } printf("\n"); fgets(str,sizeof(str),stdin); } }