⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.cpp

📁 本程序用于解决数据信息(主要是字符串信息)的哈夫曼编码
💻 CPP
字号:
//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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -