请问谁有huffman编码源代码,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/16 00:30:09
C语言的,谢谢
麻烦各位大虾帮帮忙,小弟急用
是压缩用的那个,不要多大,只要能处理四位的文件就行了

////只供参考..最好自己写一个吧
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <conio.h>

typedef struct {
unsigned int weight;
unsigned int parent,lchild,rchild;
} HTNode,*HuffmanTree;

typedef char **HuffmanCode;

typedef struct {
unsigned int s1;
unsigned int s2;
} MinCode;

void Error(char *message);
HuffmanCode HuffmanCoding(HuffmanTree HT,HuffmanCode HC,unsigned int *w,unsigned int n);
MinCode Select(HuffmanTree HT,unsigned int n);

void Error(char *message)
{
fprintf(stderr,"Error:%s\n",message);
exit(1);
}

HuffmanCode HuffmanCoding(HuffmanTree HT,Huffman