电文加密的算法是:将字母 A 变成字母 G,a 变成 g,B 变成 H,b 变成 h,依此类推,并且 U 变成 A,V 变成 B,等等。从键盘输入一个电文字符,输出其相应的密码。(提示查看ASCⅡ表)
程序代码:
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
char ch;
scanf("%c",&ch);
if(ch<=90)
{
if(ch<85)
ch=ch+6;
else
ch=ch-20;
}
else
{
if(ch<117)
ch=ch+6;
else
ch=ch-20;
}
printf("Code=%c\n",ch);
return 0;
}