1. 程式人生 > >字串加密(程式設計)

字串加密(程式設計)

Description

通過鍵盤輸入一個字串,之後按如下規律對其加密:

A→Z a→z

B→Y b→y

C→X c→x

即將字串中的第i個大寫或小寫英文字母變成相應的第(26-i+1)個大寫或小寫字母,其他字元不變。

Input

輸入一個字串,不超過100個字元。

Output

輸出為加密後的字串

Sample Input

ABCabc

Sample Output

ZYXzyx

HINT

Append Code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char ch[101];
    int m,i,kk;
    scanf("%s",ch);
    m=strlen(ch);//包含在string.h標頭檔案裡
    for(i=0;i<m;i++)
    {
        kk=ch[i];
        if(kk>='A'&&kk<='Z')
            ch[i]='Z'-ch[i]+'A';
        else if(kk>='a'&&kk<='z')
            ch[i]='z'-ch[i]+'a';
        printf("%c",ch[i]);
    }
    return 0;
}