#include<map>
#include<iostream>
#include<string>
using namespace std;
struct BTreeNode
{
int weight;
char value;
struct BTreeNode* left;
struct BTreeNode* right;
};
struct BTreeNode* CreateHuffman(int weight[],char value[], int n)
{
int i, j;
struct BTreeNode **b, *q;
b = (BTreeNode **) malloc(n*sizeof(struct BTreeNode));
for (i = 0; i < n; i++) //初始化b指针数组,使每个指针元素指向a数组中对应的元素结点
{
b[i] = (BTreeNode *) malloc(sizeof(struct BTreeNode));
b[i]->weight= weight[i];
b[i]->value=value[i];
b[i]->left = b[i]->right = NULL;
}
for (i = 1; i < n; i++)//进行 n-1 次循环建立哈夫曼树
{
//k1表示森林中具有最小权值的树根结点的下标,k2为次最小的下标
int k1 = -1, k2;
for (j = 0; j < n; j++)//让k1初始指向森林中第一棵树ÿ