哈夫曼编码源程序解释.docxVIP

  • 1
  • 0
  • 约6千字
  • 约 6页
  • 2019-09-27 发布于广东
  • 举报
哈夫曼编码 一、源程序 #includestdio.h #includestdlib.h includestring.h includcconio.h /* Huffman树的存储结构*/ #define n 8 /*叶子数目根据需要设定*/ #define m 2*n-l /* Huffman 树屮结点总数 */ typedef struct {int weight; /*结点的权值*/ int lchild,rchild,parent; /*左、右孩子及双亲的卜?标*/ Jhtnode; typedef htnode huffmantreefm+1 ];/* huffmantree是结构数纟fl类型,其()号单元不用,存储哈夫 曼树*/ typedef struct {char ch; /*存储字符*/ char code[n+1 ]; /*存放编码位串*/ } codenode; typedef codenode huffmancode[n+1 ];/*huffmancode是结构数组类型,其0号单元不用,存储哈夫 曼编码*/ void inithuffmantree(huffmantree ht) /*初始化哈夫曼树函数 inithuffmantree()*/ {inti; for(i=0;i=m;i++) {ht[i].weight=O; ht[ij」child=ht[i

文档评论(0)

1亿VIP精品文档

相关文档