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