2.解密

来源:互联网 发布:打字软件官方下载 编辑:程序博客网 时间:2024/06/06 18:22

2.完成decrypt函数,实现解密功能:将任意密文实现解密输出。
加密规则:字符串中所有小写英文字母循环加密。如a到b,b到c,…,z到a。
如输入az ibwf b mjuumf bqqmf!,输出为:zy have a little apple!

#include <stdio.h>#include <string.h>void encrypt(char *s){    **int l=strlen(s);    for(int i=0;i<l;i++)    {        if(s[i]=='a') s[i]='z';        else if(s[i]>='b'&&s[i]<='z') s[i]--;    }**}int main(){    char t1[80],ch;    gets(t1);    printf("\nthe original data is :%s",t1);    encrypt(t1);    printf("\nthe resulted data is :%s",t1);    printf("\n");    return 0;}
原创粉丝点击