C语言Huffman树

来源:百度知道 编辑:UC知道 时间:2024/07/03 05:16:57
帮忙写个主函数
谢谢了
实现26个英文字母的编码
权值自订

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct HuffmanNode
{
char data;
int weight;
int parent;
int lchild;
int rchild;
}HuffmanNode,*HuffmanTree;
typedef char **HuffmanCode;

void select(HuffmanTree HT,int n,int *s1,int *s2)
{
int i;
(*s1)=(*s2)=0;
for(i=1;i<=n;i++){
if(HT[i].weight<HT[(*s2)].weight&&HT[i].parent==0&&(*s2)!=0)
{
if(HT[i].weight<HT[(*s1)].weight)
{
(*s2)=(*s1);
(*s1)=i;
}
else (*s2)=i;
}
if(((*s1)==0||(*s2)==0)&&HT[i].parent==0)
{
if((*s1)==0)
(*s1)=i;
else if((*s2)==0)
{
if(HT[i].weight<HT[(*s1)].weight)
{
(*s2)=(*s1);
(*s1)=i;
}
else (*s2)=i;
}
}
}
if((*s1)>(*

我穿过大半个城市
晕眩。俯在酒吧的桌上
我从静止的葡萄藤间流去,
我坐在屋顶下这避风的地方
我的睡眠里
让亢奋的激情把夜晚扶起哈哈

不会