手机版网站模板下载,wordpress 是否登录,获取网站域名,wordpress如何修改字体有一行电文#xff0c;已按下面规律译成密码#xff1a;
A→Za→Z
B→Yb→y
C→Xc→X
即第1个字母变成第26个字母#xff0c;第2个字母变成第25个字母#xff0c;第i个字母变成第#xff08;26-i十1#xff09;个字母。非字母字符不变。假如已知道密码是Umtorhs…有一行电文已按下面规律译成密码
A→Za→Z
B→Yb→y
C→Xc→X
即第1个字母变成第26个字母第2个字母变成第25个字母第i个字母变成第26-i十1个字母。非字母字符不变。假如已知道密码是Umtorhs要求编程序将密码译回原文并输出密码和原文。
#include stdio.h
#include string.h
#include ctype.h// 解密函数
void decrypt(char* ciphertext, char* plaintext) {int i, j;int len strlen(ciphertext);for (i 0, j 0; i len; i) {if (isalpha(ciphertext[i])) {char ch ciphertext[i];if (ch A ch Z) {ch A (26 - (ch - A 1) 1);if (ch Z) ch - 26;}else if (ch a ch z) {ch a (26 - (ch - a 1) 1);if (ch z) ch - 26;}plaintext[j] ch;}else {plaintext[j] ciphertext[i];}}plaintext[j] \0;
}int main() {char ciphertext[100];char plaintext[100];// 提示用户输入密码printf(请输入加密后的密码\n);fgets(ciphertext, sizeof(ciphertext), stdin);// 去除fgets读入的换行符如果存在if (ciphertext[strlen(ciphertext) - 1] \n) {ciphertext[strlen(ciphertext) - 1] \0;}decrypt(ciphertext, plaintext);printf(原文%s\n, plaintext);printf(密码加密后%s\n, ciphertext);return 0;
}