#include <stdio.h>

int main() { char str[100]; printf("请输入字符串:"); scanf("%[^ ]", str); // 读入带空格的字符串,以回车符结束 getchar(); // 将回车符从缓冲区中读出

int i = 0;
while (str[i] != '\0') { // 遍历字符串中的每个字符
    if (str[i] >= 'a' && str[i] <= 'w') { // a~w往后移3位
        str[i] += 3;
    } else if (str[i] >= 'x' && str[i] <= 'z') { // x~z变成a~c
        str[i] -= 23;
    }
    printf('%c', str[i]); // 输出移位后的字符
    i++;
}

return 0;

}

C语言实现字符串移位加密

原文地址: https://www.cveoy.top/t/topic/oJVD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录