没有合适的资源?快使用搜索试试~ 我知道了~
自己在大学时写的用霍夫曼算法求霍夫曼编码,希望可以对大家有帮助
资源推荐
资源详情
资源评论
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define N 5 //权向量的个数
typedef int elemtype;
struct Tree
{
elemtype weight;
elemtype lchild;
char rchild;
elemtype parents;
};
void HuffmanTree(int *w); //构造霍夫曼树
#include "tree.h"
void HuffmanTree(int *w)
{
int i,j,k,m,x,y,n,p,f,s;
char c,*code[N],cod[N];
Tree *t;
m=2*N-2;
c=97;
t=(Tree*)malloc(m*sizeof(Tree));
for(i=1;i<N;i++) //给叶子结点赋值
{
(t+i)->weight=w[i];
(t+i)->parents=0;
(t+i)->lchild=i;
(t+i)->rchild=c;
c++;
}
#include "stdlib.h"
#include "string.h"
#define N 5 //权向量的个数
typedef int elemtype;
struct Tree
{
elemtype weight;
elemtype lchild;
char rchild;
elemtype parents;
};
void HuffmanTree(int *w); //构造霍夫曼树
#include "tree.h"
void HuffmanTree(int *w)
{
int i,j,k,m,x,y,n,p,f,s;
char c,*code[N],cod[N];
Tree *t;
m=2*N-2;
c=97;
t=(Tree*)malloc(m*sizeof(Tree));
for(i=1;i<N;i++) //给叶子结点赋值
{
(t+i)->weight=w[i];
(t+i)->parents=0;
(t+i)->lchild=i;
(t+i)->rchild=c;
c++;
}
资源评论
buyinuan
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功