huffman编码实现 w = {2,3,5,7,11,13,17,19,23,29,31,37,41}谢谢了···
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 15:48:47
huffman编码实现 w = {2,3,5,7,11,13,17,19,23,29,31,37,41}谢谢了···
huffman编码实现 w = {2,3,5,7,11,13,17,19,23,29,31,37,41}谢谢了···
huffman编码实现 w = {2,3,5,7,11,13,17,19,23,29,31,37,41}谢谢了···
41:111
37:110
31:100
29:010
23:001
19:000
17:1010
13:0111
11:0110
7:10110
5:101110
3:1011111
2:1011110
Huffman编码结果不唯一哦!
下面附上参考程序哈:
void Error(char *message) //错误提示
{
system("cls"); //清屏
fprintf(stderr,"Error:%s\n",message); //显示错误信息
exit(1);
}
HuffmanCode HuffmanCoding(HuffmanTree HT,HuffmanCode HC,unsigned int *w,unsigned int n) //Huffman编码函数,先构建Huffman树
{
unsigned int i,s1=0,s2=0;
HuffmanTree p;
char *cd;
unsigned int f,c,start,m;
MinCode min;
if(nparent=0;
p->lchild=0;
p->rchild=0;
}
for(;iweight=0;
p->parent=0;
p->lchild=0;
p->rchild=0;
}
for(i=n+1;i