/* 功能:字符加密 日期:2013-04-01 */ #include<stdio.h> #include<stdlib.h> #include<math.h>
int main(void) { char One,Two,Three,Four,Five; printf("请输入5个字符:"); scanf("%c%c%c%c%c",&One,&Two,&Three,&Four,&Five);
if (One>=97&&One<=122)//第一个字符 { One=( One + 4 - 97 ) % 26 + 'a';
} if(One>=65&&One<=90) { One=( One + 4 - 65 ) % 26 + 'A'; } if (Two>=97&&Two<=122)//第二个字符 { Two=(Two + 4 - 97 ) % 26+'a'; } if (Two>=65&&Two<=90) { Two=(Two + 4 -65 ) % 26 + 'A'; } if (Three>=97&&Three<=122)//第三个字符 { Three=( Three + 4 - 97 ) % 26 + 'a'; } if (Three>=65&&Three<=90) { Three=(Three + 4 - 65 ) % 26 + 'A'; } if (Four>=97&&Four<=122)//第四个字符 { Four=( Four + 4 - 97 ) % 26 + 'a'; } if ( Four>=65&&Four<=90) { Four=(Four + 4 - 65 ) % 26 + 'A'; } if ( Five>=97&&Five<=122)//第五个字符 { Five=( Five + 4 - 97 ) % 26 + 'a'; } if (Five>=65&&Five<=90) { Five=( Five + 4 - 65 ) % 26 + 'A'; } printf("加密后的数值是:%c%c%c%c%cn",One,Two,Three,Four,Five); system("pause");
return 0; }