加密解密

来源:互联网 发布:linux c语言编程 编辑:程序博客网 时间:2024/05/29 09:42
#include <stdio.h>#define MAXN 100void encodeCourse(void);void decodeCourse(void);int main(void){char c;while(scanf("%c",&c)==1){if(c=='1'){encodeCourse();}else if(c=='0'){decodeCourse();}}return 0;}void encodeCourse(void){char encodedChar[MAXN];int c;printf("There are Words needed to be encodedCourse:");int i=0;while(scanf("%c",&c)==1){if(c>='a'&&c<'x'){c+=3;}else if(c>='x'&&c<='z'){c-=23;}encodedChar[i++]=c;}encodedChar[i]='\0';printf("\nThere are encodedWords:%s\n",encodedChar);} void decodeCourse(void){char decodedChar[MAXN];int c;printf("There are words needed to be decodedCourse: ");int i=0;while(scanf("%c",&c)==1){if(c>'c'&&c<='z'){c-=3;}else if(c>='a'&&c<='c'){c+=23;}decodedChar[i++]=c;}decodedChar[i]='\0';printf("\nThere are decodedWords:%s\n",decodedChar);}

0 0