【www.gdgbn.com--php应用】


#include
#include
#include
#includea
#include
#define MAXVALUE 200           /*权值的最大值*/
#define MAXBIT  30             /*最大的编码位数*/
#define MAXNODE 30             /*初始的最大的结点数*/
 struct haffnode
         {char data;
   int weight;
                        int flag;
                        int parent;       /*双亲结点的下标*/
                        int leftchild;    /*左孩子下标*/
                        int rightchild;   /*右孩子下标*/
         };
 struct haffcode
         {int bit[MAXNODE];
                        int start;        /*编码的起始下标*/
   char data;
   int weight;       /*字符权值*/
         };

 


/*函数说明*/
/************************************************************************/
void pprintf(struct haffcode haffcode[],int n);
/*输出函数*/
void haffmantree(int weight[],int n,struct haffnode hafftree[],char data[]);
/*建立哈夫曼树*/
void haffmancode(struct haffnode hafftree[],int n,struct haffcode haffcode[]);
/*求哈夫曼编码*/
void test(struct haffcode haffcode[],int n);
/*测试函数*/
void end();
/*结束界面函数*/
/************************************************************************/

 


本文来源:http://www.gdgbn.com/jiaocheng/13113/