凯撒算法

王朝百科·作者佚名  2012-05-11  
宽屏版  字体:   |    |    |  超大  

凯撒密码是一种非常古老的加密方法,相传当年凯撒大地行军打仗时为了保证自己的命令不被敌军知道,就使用这种特殊的方法进行通信,以确保信息传递的安全。他的原理很简单,说到底就是字母于字母之间的替换

# include<stdio.h>

main()

{

int key;

char mingma,mima;

printf("

Please input the character:");

getch();

scanf("%c",&mingma);

printf("

Please input the key:");

getch();

scanf("%d",&key);

if((mingma>='A')&&(mingma<='Z'))

mima='A'+(mingma-'A'+key)%26;

if((mingma>='a')&&(mingma<='z'))

mima='a'+(mingma-'a'+key)%26;

printf("

The output is:%c",mima);

getch();

}

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有