test.cpp

来自「本程序用于解决数据信息(主要是字符串信息)的哈夫曼编码」· C++ 代码 · 共 64 行

CPP
64 行
字号
//for test
#include <iostream>
#include<fstream>
#include "HaffCode.h"

using namespace std;

void main()
{
	
	try{
		
		CHaffCode test;//创建哈夫曼树
		
		char choice;
		do
		{
			cout<<endl;
			cout<<"编码译码请输入      :E"<<endl;
			cout<<"译码请输入          :D"<<endl;
			cout<<"打印哈夫曼树请输入  :T"<<endl;
			cout<<"打印哈夫曼编码请输入:C"<<endl;
			cout<<"退出请输入          :Q"<<endl;
			
			cout<<endl<<"请输入选项:";
			cin>>choice;
			
			if(choice == 'E'||choice == 'e')
			{
				test.encode();
				cout<<"编码完成,文件的编码结果已存入指定文件"<<endl;
			}
			else if(choice == 'T'||choice == 't')
			{
				test.printHafftree();
			}
			else if(choice == 'C'||choice == 'c')
			{
				test.printHaffCode();
			}
			else if(choice == 'D'||choice == 'd')
			{
				test.decode();
				cout<<endl;
				cout<<"译码完成,文件已写入指定文件"<<endl;
			}
			else if(choice == 'Q'||choice == 'q')
			{
				cout<<endl;
				cout<<"Thanks for using!Bye!"<<endl;
			}
			else
			{
				cout<<"输入错误!"<<endl;
			}
		}while(choice != 'q'&&choice != 'Q');
		
	}
	catch (int)
	{
		return;
	}
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?