#include#include #define N 50 //叶子结点数#define M 2*N-1 //树中结点总数typedef struct//哈夫曼树的节点{ char data[5]; //结点存储的单词 int weight; //权重(该单词出现次数) int parent; //双亲结点 int lchild; //左孩子结点 int rchild; //右孩子结点} HTNode;typedef struct//哈夫曼编码{ char cd[N]; //叶子节点对应的哈夫曼编码 int start; //指向哈夫曼编码cd[]的最开始字符(从下标start开始到n为有效的哈夫曼编码)} HCode;void CreateHT(HTNode ht[],int n);//构造void CreateHCode(HTNode ht[],HCode hcd[],int n);//编码void DispHCode(HTNode ht[],HCode hcd[],int n);//输出编码void main(){ int n=15;//15个单词(叶节点) ////初始化 char *str[]={ "The","of","a","to","and","in","that","he","is","at","on","for","His","are","be"}; int fnum[]={ 1192,677,541,518,462,450,242,195,190,181,174,157,138,124,123}; HTNode ht[M];//节点 HCode hcd[N];//编码 for (int i=0;i