2024年4月21日发(作者:)

#include "stdio.h"

#include "stdlib.h"

#include "conio.h"

#define LEN sizeof(HFtree) /*HFtree结构体大小*/

/*哈夫曼树结构体*/

typedef struct tagHFtree

{

char data; /*结点数据,以后用到*/

double weight; /*结点的权重*/

struct tagHFtree* parent; /*双亲结点*/

struct tagHFtree* lchild; /*左孩子*/

struct tagHFtree* rchild; /*右孩子*/

struct tagHFtree* next; /*指向下一个结点*/

}HFtree;

/*哈夫曼编码结构体*/

struct tagHFcode

{

char data; /*结点数据*/

double weight; /*结点的权重*/

int code[20]; /*存放编码*/

int top; /*编码的位数*/

};

/***********************************************

创建哈夫曼树核心部分

************************************************/

void Create(HFtree**head)