C语言编程题,求助,谢谢!

2024-11-26 18:37:44
推荐回答(1个)
回答1:

#include

#include

int main() {

int i;

char s[80];

printf("请输入字符串:");

while(scanf("%s",s) == 1) {

printf("加密前:%s\n",s);

i = 0;

while(s[i]) {

if(s[i] >= 'A' && s[i] <= 'Z')

s[i] = (s[i] - 'A' + 3)%26 + 'A';

else if(s[i] >= 'a' && s[i] <= 'z')

s[i] = (s[i] - 'a' + 3)%26 + 'a';

++i;

}

printf("加密后:%s\n",s);

printf("请输入字符串[结束程序]:");

}

return 0;

}