#include "stdafx.h"#include "stdio.h" #include "string.h" #include"stdlib.h" void Cryptogram(); void Ansert(); void Menu(); void Cryptogram() { int result = 1; int i ; int count = 0; char Text[128]={'\0'}; char cryptograph[128]={'\0'}; printf("請輸入要加密的明文:\n"); scanf("%s",&Text); count = strlen(Text); for ( i =0;i<count;i++) { cryptograph[i] =Text[i]+i+5; } cryptograph[i] ='\0'; printf("加密後的密文是: %s\n",cryptograph); } void Ansert() { int result = 1; int i ; int count = 0; char Text[128]={'\0'}; char cryptograph[128]={'\0'}; printf("請輸入密文:\n"); scanf("%s",&cryptograph); count = strlen(cryptograph); for ( i =0;i<count;i++) { Text[i]; cryptograph[i]-i-5; } Text[i] ='\0'; printf("解密後的密碼是: %s\n",Text); } void Menu() { printf("\t請選擇你希望的操作!\n"); printf("\t--------------------\n"); printf("\t 1.加密處理!\n"); printf("\t 2.解密處理! \n"); printf("\t 3.退出程式! \n"); printf("\t--------------------\n"); } int main() { while(1) { Menu(); int i; printf("請選擇:"); scanf("%d",&i); switch(i) { case 1: Cryptogram(); break; case 2: Ansert(); break; case 3:exit(0); default: printf("選擇錯誤!"); } system("pause"); system("cls"); } }