㈠ 用C语言编程恺撒密码加密解密程序
#include<stdio.h>
#defineisletter(c)(((c)>='a'&&(c)<='z')||((c)>='A'&&(c)<='Z'))
voidEnc(constchar*str,char*out,intkey)
{
inti=0;
while(str[i])
{
if(isletter(str[i]))
{
out[i]=嫌知str[i]+key;
if(!isletter(out[i]))
out[i]-=26;
}
else
芦指out[i]=str[i];
i++;
}
out[i]=0;
}
voidDenc(constchar*str,char*out,intkey)
{
inti=0;
while(str[i])
{
if(isletter(str[i]))
{
out[i]=str[i]-key;
if(!isletter(out[i]))
陪者配out[i]+=26;
}
else
out[i]=str[i];
i++;
}
out[i]=0;
}
intmain()
{
charout[100],out2[100];
Enc("",out,3);
printf("%s ",out);
Denc(out,out2,3);
printf("%s ",out2);
}