文章
4
粉丝
204
获赞
3
访问
12.6k
#include<bits/stdc++.h>
using namespace std;
typedef struct Node {
int weight;
int parent, lchild, rchild;
}Node,HaffumanTree[20000];
void createHaffumanTree(int weight[],int n,HaffumanTree t) {
for (int i = 0; i < 2 * n - 1; i++) { //初始化哈夫曼树
t[i].parent = -1;
t[i].lchild = -1;
t[i].rchild = -1;
if (i < n) {
t[i].weight = weight[i];
}
else {
t[i].weight = 0;
}
}
for (int i = n; i < 2 * n - 1; i++) {
int p1 = 0,p2 = 0; //p1指向最小节点,...
登录后发布评论
暂无评论,来抢沙发