⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 huffman.cpp

📁 初学者学习c语言数据结构的编码
💻 CPP
字号:
#include <malloc.h>
#include <stdlib.h>
#include <iostream.h>

#define true 1
#define false 0
#define OK 1
#define Error 0
#define INFEASIBLE -1
#define OVERFLOW -2

typedef int Elemtype;
typedef int Status;

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

typedef char* *HuffmanCode;

void select(HuffmanTree HT, int i, int &s1, int &s2)

void HTcoding(HuffmanTree &HT, HuffmanCode &HC, int *w, int n){
	if(n<=1)return;
	int m=2*n-1;
	int i;
	HuffmanTree p;
	HT=(HuffmanTree)malloc((m+1)*sizeof(HTNode));
	for(p=HT, i=1;i<=n;i++,w++,p++){
		p->lchild=p->parent=p->rchild=0;
		p->weight=*w;
	}
	for(;i<=m;i++,p++)p->lchild=p->parent=p->rchild=p->weight=0;
	
}

void main(){
	int* w;
	w=(int*)malloc(4*sizeof(int));
	int* kkk=w;
	for(int i=1;i<=4;i++,w++)*w=i;
	for(int j=0;j<=3;j++)cout<<kkk[j]<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -