哈夫曼树的建立及编码
#include<stdio.h>
#include<stdlib.h>
#define N 20
#define M 2*N-1
typedef struct{
int weight; //权值
int parent; //双亲
int lchild; //左孩子
int rchild; //右孩子
}huffmantree;
typedef struct{
int start;
char codes[N]; //存哈夫曼的编码
}huffmancode;
void creathuffman(huffmantree tree[],int n){
int i,j,w,p1,p2,small1,small2;
int m = 2*n;
for (i=1;i<m;i++){
//初始化
tree[i].weight = 0;
tree[i].lchild = 0;
tree[i].rchild = 0;
tree[i]