#include #include #include #define n 6 #define m 2*n-1 typedef struct { float weight; int lchild,rchild,parent; }codenode; typedef codenode huffmantree[m]; typedef struct { char ch; char bits[n+1]; }code; typedef code huffmancode[n]; void inithf(huffmantree T) //-哈夫曼树的初始化 { int i; for(i=0;i=0) { cd[--start]=(T[p].lchild==c)?'0':'1'; c=p; } strcpy(H[i].bits,&cd[start]); } } void zip(huffmancode H,char *ch,char *s) //-编码 { int j=0;char *p[n]; unsigned int i; for(i=0;i