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

  • 6
  • 0
  • 约 5页
  • 2016-12-30 发布于重庆
  • 举报
哈夫曼编码 一、源程序 #includestdio.h #includestdlib.h #includestring.h #includeconio.h /* Huffman 树的存储结构*/ #define n 8 /*叶子数目根据需要设定*/ #define m 2*n-1 /* Huffman 树中结点总数 */ typedef struct {int weight; /*结点的权值*/ int lchild,rchild,parent; /*左、右孩子及双亲的下标*/ }htnode; typedef htnode huffmantree[m+1];/* huffmantree是结构数组类型,其0号单元不用,存储哈夫曼树 */ typedef struct {char ch; /*存储字符*/ char code[n+1]; /*存放编码位串*/ }codenode; typedef codenode huffmancode[n+1];/*huffmancode是结构数组类型,其0号单元不用,存储哈夫曼编码*/ void inithuffmantree(huffmantree ht) /*初始化哈夫曼树函数inithuffmantree()*/ {int i; for(i=0;i=m;i++) {ht[i].weight=0; h

文档评论(0)

1亿VIP精品文档

相关文档