- 6
- 0
- 约2.75千字
- 约 4页
- 2016-11-22 发布于江西
- 举报
信息论实验报告1new.doc
三、详细设计
1.Huffman编码
#includeiostream.h
#includestdio.h
#includemalloc.h
typedef struct node{
node * lchild;
node * rchild;
char data;
int weight;
}* tree;
struct elemtype{
char ch;
int weight;
int code[10];
};
int N=0,m=0;
void savetree(char *str){
FILE *fp=fopen(1.txt,w);
for(int i=0;im;i++){
fputc(str[i],fp);}
fclose(fp);
}
void createhuffman(tree T,elemtype ** a,int n){
int i=0,j,k1,k2;btree * b;btree q;
b=(btree * )malloc(n*sizeof(tree));
for(i=0;in;i++){
b[i]=(bnode *)malloc(sizeof(node));
b[i]
原创力文档

文档评论(0)