?? menuchoose.cpp
字號:
#include"Huffmanhead.h"
extern *w;
extern weight[MAX],WeightTemp[123];
extern char CodeTemp[MAX];
extern char ShuruName[MAX],ShuruStr[MAX],HC[MAX][MAX];
extern HuffmanTree HT[MAX];
int n,ITure=0;//ITure用于判斷是否已經進行初始化,n用于存放字符數
void MenuChoose()
{
printf("\n");
printf("Menu=");
char choosechar;
w=weight;
choosechar=getchar();
printf("\n");
do{
switch(choosechar)
{
case 'i':
if(ITure==0)
{
fflush(stdin);//清除殘留在內存中的回車符
n=ShuruString(ShuruStr)-1;
HuffmanTreeBulid(HT,w,n);
ITure=1;
HuffmanCoding(HT,CodeTemp,n);
PrintHuffmanCode(n);
fflush(stdin);//清除殘留在內存中的回車符
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
}
else
{
printf("The coding is OK now,if you want to reset,please choose‘R’to reset!\n\n");
}
break;
case 'I':
if(ITure==0)
{
fflush(stdin);//清除殘留在內存中的回車符
n=ShuruString(ShuruStr)-1;
HuffmanTreeBulid(HT,w,n);
ITure=1;
HuffmanCoding(HT,CodeTemp,n);
PrintHuffmanCode(n);
fflush(stdin);//清除殘留在內存中的回車符
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
}
else
{
printf("The coding is OK now,if you want to reset,please choose‘R’to reset!\n\n");
}
break;
case 'c':
if(ITure==1)
{
fflush(stdin);//清除殘留在內存中的回車符
printf("Please input the code which you want to coding:\n\n");
printf("NewShuruStr=");
gets(ShuruStr);
fflush(stdin);//清除殘留在內存中的回車符
PrintHuffmanCode(n);
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
}
else
{
printf("You havn't input the code to initialize the application!Please input initialize first:\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
fflush(stdin);//清除殘留在內存中的回車符
MenuChoose();
}
break;
case 'C':
if(ITure==1)
{
fflush(stdin);//清除殘留在內存中的回車符
printf("Please input the code which you want to coding:\n\n");
printf("NewShuruStr=");
gets(ShuruStr);
fflush(stdin);//清除殘留在內存中的回車符
PrintHuffmanCode(n);
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
}
else
{
printf("You havn't input the code to initialize the application!Please input initialize first:\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
fflush(stdin);//清除殘留在內存中的回車符
MenuChoose();
}
break;
case 'd':
if(ITure==1)
{
fflush(stdin);//清除殘留在內存中的回車符
DecryptCoding(ShuruName,HT,n);
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
}
else
{
printf("You havn't input the coding to initialize the application!Please input initialize first:\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
fflush(stdin);//清除殘留在內存中的回車符
MenuChoose();
}
break;
case 'D':
if(ITure==1)
{
fflush(stdin);//清除殘留在內存中的回車符
DecryptCoding(ShuruName,HT,n);
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
}
else
{
printf("You havn't input the coding to initialize the application!Please input initialize first:\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
fflush(stdin);//清除殘留在內存中的回車符
MenuChoose();
}
break;
case 'r':
fflush(stdin);//清除殘留在內存中的回車符
ITure=ResetAll();
printf("Reset ok now!\n\n");
break;
case 'R':
fflush(stdin);//清除殘留在內存中的回車符
ITure=ResetAll();
printf("Reset ok now!\n\n");
break;
case 's':
fflush(stdin);//清除殘留在內存中的回車符
printf("This application is designed by alphalwei,and the GuideTeacher is WangMingLi!\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
break;
case 'S':
fflush(stdin);//清除殘留在內存中的回車符
printf("This application is designed by alphalwei,and the GuideTeacher is WangMingLi!\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
break;
case 'e':
exit(0);
break;
case 'E':
exit(0);
break;
default:
printf("You are input a wrong parameter,please choose again:\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
fflush(stdin);//清除殘留在內存中的回車符
MenuChoose();
}
printf("Please choose again:\n");
fflush(stdin);
MenuChoose();
}while(choosechar!='e'&&choosechar!='E');
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -