下面使用c++写的已调试通过,
//* * * * * * * * * * * * * * * * * * * * * * * * 【程序编程相关:[音乐天堂]Canon(弦乐版)】 【推荐阅读:asp.net 2.0中一次性更新所有G】//*program :哈夫曼树 * 【扩展信息:从袁隆平获国际大奖想到的(转)】 //*content :构造哈夫曼树,哈夫曼编码 * //* * * * * * * * * * * * * * * * * * * * * * * * #include <dos.h> #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct {unsigned int weight; //结点权值 unsigned int parent,lchild,rchild; //结点的父指针,左右孩子指针 }htnode,*huffmantree; //动态分配数组存储哈夫曼树 typedef char **huffmancode; //动态分配数组存储哈夫曼编码表 void createhuffmantree(huffmantree &,unsigned int*,int ); //生成一棵哈夫曼树 void huffmancoding(huffmantree,huffmancode &,int ); //对哈夫曼树进行编码 void printhuffmancode(huffmancode,unsigned int*,int); //显示哈夫曼编码 void select(huffmantree,int,int&,int&); //在数组中寻找权值最小的两个结点 void main() { huffmantree ht; //哈夫曼树ht huffmancode hc; //哈夫曼编码表hc ... 下一页