先编写函数EncryptChar,按照下述规则将给定的字符c转化(加密)为新的字符

/*
先编写函数EncryptChar,按照下述规则将给定的字符c转化(加密)为新的字符:
"A"转化"B","B"转化为"C",... ..."Z"转化为"a","a"转化为"b",... ..., "z"转化为"A",其它字符不加密。
编写程序,加密给定字符串。
*/
#include <stdio.h>
#include<string.h>
void EncryptChar(char st[],int n){
    int i;
    for(i=0;i<n;i++){
        if(st[i]=='Z')
            st[i]='a';
        else if(st[i]=='z')
            st[i]='A';
        else{
            st[i]=st[i]+1;
        }
    }
}
int main()
{
    char st[100];
    gets(st);
    int n=strlen(st);
    EncryptChar(st,n);
    puts(st);
    return 0;
}
原文地址:https://www.cnblogs.com/zhaohuan1996/p/11934671.html