C語言如何編寫凱撒加密,凱撒密碼 c語言

 2023-12-06 阅读 30 评论 0

摘要:編程語言 c語言 實現功能 實現凱撒密碼(寫的比較簡潔,也不是很智能) 學習內容方向 密碼學 實現原理 密文每個字母向后移3位,然后變成對應的大寫字母,xyz對應變為abc 代碼 #include <stdio.h> #include <string.h>int main() {

編程語言

c語言

實現功能

實現凱撒密碼(寫的比較簡潔,也不是很智能)

學習內容方向

密碼學

實現原理

密文每個字母向后移3位,然后變成對應的大寫字母,xyz對應變為abc

代碼

#include <stdio.h>
#include <string.h>int main()
{char input[50] = { 0 };printf("請輸入明文(a-z):");scanf("%s", input);//char ch = getchar();int i = 0;while ((input[i]) != '\0')//遍歷明文中各元素直到0{if (input[i] >= 'x')//x及之后的字母input[i] = input[i] - 23 - 32;else//x之前的字母input[i] = input[i] + 3 - 32;i++;}printf("密文為:");printf("%s", input);return 0;
}

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/194712.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息