凯撒密码实现
#include <stdio.h> int main() { // 凯撒加密,明文中字母按字母表左移或者右移三位,这里右移 char input[6] = "hello"; char output[6]; int key = 3; int i,j; for (i = 0; i < 5; i++) { int a = input[i]; a += 3; output[i] = (char)a; } output[i] = '\0'; printf("加密后:%s\n", output); for (j = 0; j < 5; j++) { int b = output[j]; b -= 3; input[j] = (char)b; } input[j] = '\0'; printf("解密后:%s", input); return 0; }