本文最后更新于 1451 天前,其中的信息可能已经有所发展或是发生改变。
#include<stdio.h>
#include<string.h>
int main()
{
char plaintext[100] = { 0 }, ciphertext[100] = { 0 };
printf("请输入明文:");
gets(plaintext);
for (unsigned int i = 0; i <= strlen(plaintext); i++) {
if (plaintext[i] >= 65 && plaintext[i] <= 90) {
if (plaintext[i] >= 87 && plaintext[i] <= 90) {
ciphertext[i] = plaintext[i] - 22;
}
else if (plaintext[i] <= 86 && plaintext[i] >= 65) {
ciphertext[i] = plaintext[i] + 4;
}
}
else if (plaintext[i] >= 97 && plaintext[i] <= 122) {
if (plaintext[i] >= 119 && plaintext[i] <= 122) {
ciphertext[i] = plaintext[i] - 22;
}
else if (plaintext[i] >= 97 && plaintext[i] <= 118) {
ciphertext[i] = plaintext[i] + 4;
}
}
else if (plaintext[i] == '#')break;
else if (plaintext[i] >= 33 && plaintext[i] <= 64) {
ciphertext[i]=plaintext[i];
}
}
printf("密文为:%s", ciphertext);
return 0;
}
哎呀明明可以把大小写字母判定用或符连起来,还整这么多行
明明直接用字符就行了,还查了一大堆ascii码
一开始用while来个getchar()!=’#’就完事了
老憨批了