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

📄 haffcode.h

📁 本程序用于解决数据信息(主要是字符串信息)的哈夫曼编码
💻 H
字号:
// HaffCode.h: interface for the CHaffCode class.
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HAFFCODE_H__73ABB907_1513_46CA_8D72_6D97A6F1DE11__INCLUDED_)
#define AFX_HAFFCODE_H__73ABB907_1513_46CA_8D72_6D97A6F1DE11__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

const int maxbit = 10;


//哈夫曼树的结点结构
struct element
{
	char ch;
	int weight;
	int lch,rch,pa;
};

//哈夫曼编码的结构
struct code
{
	int bit[maxbit];
	int start;//栈顶指针
	char ch;
	int weight;
};

class CHaffCode  
{
public:
	void printHaffCode();//输出哈夫曼编码
	void printHafftree();//输出哈夫曼树
	void decode();//解码
	void encode();//编码
	CHaffCode();
	virtual ~CHaffCode();

private:
	void count();//计算每个字符的个数
	void compile();//将Haffman树转化成Haffman编码
	code hc[50];//存储哈夫曼编码
	void hafftree();//根据权值构造哈夫曼树
	element ht[100];//存储哈夫曼树
	int num;//存储编码数
	int weight[256];//存储权值
	char ifname[255];//源文件地址
	char ofname[255];//编码地址
	char buf[255];//Haffman编码地址
	char dfname[255];//解码文件地址
};

#endif // !defined(AFX_HAFFCODE_H__73ABB907_1513_46CA_8D72_6D97A6F1DE11__INCLUDED_)

⌨️ 快捷键说明

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