教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 高等教育 >

哈夫曼编码译码系统实验报告,数据结构课程设计(4)

来源:网络收集 时间:2025-09-14
导读: ht=(struct huff *)malloc((m+1)*sizeof(struct huff)); struct huff *p; for(p=ht,i=0;i p->weight=*w; p->parent=0; p->l=0; p->r=0; } for(;i l=0; p->weight=0; p->parent=0; p->r=0; } for(i=1;i Select(ht,i-

ht=(struct huff *)malloc((m+1)*sizeof(struct huff)); struct huff *p;

for(p=ht,i=0;i<=n;i++,p++,w++) {

p->weight=*w; p->parent=0; p->l=0; p->r=0; }

for(;i<=m;i++,p++) { p->l=0; p->weight=0; p->parent=0; p->r=0; } for(i=1;i<=4;i++) for(i=n+1;i<=m;i++) { int s1,s2;

Select(ht,i-1,s1,s2); ht[s1].parent=i; ht[s2].parent=i; ht[i].l=s1; ht[i].r=s2;

ht[i].weight=ht[s1].weight+ht[s2].weight; }

15

char *cd;

cd=(char *)malloc(n*sizeof(char)); cd[n-1]='\\0';

intstart,c,f; for(i=1;i<=n;++i) { start=n-1;

for(c=i,f=ht[i].parent;f!=0;c=f,f=ht[f].parent) if(ht[f].l==c) cd[--start]='0'; else

cd[--start]='1';

huffmancode[i]=(char *)malloc((n-start)*sizeof(char)); strcpy(huffmancode[i],&cd[start]); } free(cd); }

6. 用户使用手册 运行程序即可。

如果改变,可以改变文件datafile.txt,codefile.txt中的值

16

哈夫曼编码译码系统实验报告,数据结构课程设计(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/616615.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)