凯撒密码式加密
#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;
}

-EOF-
这篇文章的作者Shennoter祝你心情愉快ღゝ◡╹)ノ♡♪(^∇^)

评论

  1. 博主
    Windows Edge
    3年前
    2020-10-26 11:30:46

    哎呀明明可以把大小写字母判定用或符连起来,还整这么多行
    明明直接用字符就行了,还查了一大堆ascii码
    一开始用while来个getchar()!=’#’就完事了
    老憨批了

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇