没有合适的资源?快使用搜索试试~ 我知道了~
数据结构哈夫曼树(VC6.0程序)
1星 需积分: 2 13 下载量 143 浏览量
2016-12-28
18:40:35
上传
评论 1
收藏 4KB TXT 举报
温馨提示
试读
9页
1) 初始化(Initialzation)。利用下表给出的字符集和频度的实际统计数据建立哈夫曼树,并将它存于文件hfmTree中; 2) 编码(EnCoding)。利用已建好的哈夫曼树(若不在内存中,则从文件hfmTree中读入),对以下报文进行编码,结果存入文件CodeFile中; 报文内容:THIS PROGRAM IS MY FAVORITE 3) 译码(Decoding)。利用已建好的哈夫曼树,对文件CodeFile中编码后的报文进行解码,结果存入文件Textfile中; 4) 输出(Output)。输出字符集中每个字符的哈夫曼编码;输出原始报文,及其编码文件CodeFile和解码文件Textfile的内容。
资源推荐
资源详情
资源评论
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<stdlib.h>
#include<stdio.h>
typedef struct{
char ch;
int weight;
int parent,lchild,rchild;
}htnode,*hfmtree;
typedef char **hfmcode;
void Select(hfmtree &HT,int a,int *p1,int *p2)
{
int i,j,x,y;
for(j=1;j<=a;++j){
if(HT[j].parent==0){
x=j;
break;
}
}
for(i=j+1;i<=a;++i){
if(HT[i].weight<HT[x].weight&&HT[i].parent==0){
x=i;
}
}
for(j=1;j<=a;++j){
if(HT[j].parent==0&&x!=j)
{
y=j;
break;
#include<string.h>
#include<fstream.h>
#include<stdlib.h>
#include<stdio.h>
typedef struct{
char ch;
int weight;
int parent,lchild,rchild;
}htnode,*hfmtree;
typedef char **hfmcode;
void Select(hfmtree &HT,int a,int *p1,int *p2)
{
int i,j,x,y;
for(j=1;j<=a;++j){
if(HT[j].parent==0){
x=j;
break;
}
}
for(i=j+1;i<=a;++i){
if(HT[i].weight<HT[x].weight&&HT[i].parent==0){
x=i;
}
}
for(j=1;j<=a;++j){
if(HT[j].parent==0&&x!=j)
{
y=j;
break;
}
}
for(i=j+1;i<=a;i++)
{
if(HT[j].weight<HT[y].weight&&HT[i].parent==0&&x!=i)
{
y=i;
}
}
if(x>y){
*p1=y;
*p2=x;
}
else
{
*p1=x;
*p2=y;
}
}
void hfmcoding(hfmtree &HT,hfmcode &HC, int n)
{
int i,start,c,f,m,w;
int p1,p2;
char *cd,z;
if(n<=1){
return;
}
m=2*n-1;
HT=(hfmtree)malloc((m+1)*sizeof(htnode));
for(i=1;i<=n;i++)
}
for(i=j+1;i<=a;i++)
{
if(HT[j].weight<HT[y].weight&&HT[i].parent==0&&x!=i)
{
y=i;
}
}
if(x>y){
*p1=y;
*p2=x;
}
else
{
*p1=x;
*p2=y;
}
}
void hfmcoding(hfmtree &HT,hfmcode &HC, int n)
{
int i,start,c,f,m,w;
int p1,p2;
char *cd,z;
if(n<=1){
return;
}
m=2*n-1;
HT=(hfmtree)malloc((m+1)*sizeof(htnode));
for(i=1;i<=n;i++)
剩余8页未读,继续阅读
资源评论
- ahdvjilk2019-12-02垃圾程序,瞎写王蛋糕cake2020-01-08当时用VC6.0是可以运行成功的,可能你用的是VS无法运行。
王蛋糕cake
- 粉丝: 98
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Arduino Nano的红外循迹小车源码(高分课设).zip
- 将MS SQL数据库表里的数据内容生成SQL执行语句
- 基于MATLAB的钢板表面缺陷检测系统
- MS SQL里生成行政区域县区信息表和相应数据
- delphi实现DBGrid全选和反选功能
- 25C11F41-2B2A-4D1A-AAA8-7C654526B129.pdf
- Android Studio Jellyfish(android-studio-2023.3.1.18-cros.deb)
- MVC+EF框架+EasyUI实现权限管理源码程序
- python第66-75天,Day66-75.rar
- python后端服务project-of-tornado.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功