以下是我做个的类似的题的代码:
#include
#include
#include
#include
#include
usingnamespace std;
typedefstruct{ //哈夫曼树的结构体
char ch;
int weight; //权值
int parent,lchild,rchild;
}hnode,*hfmtree;
typedefchar **hfmcode;
void Select(hfmtree &TREE,inta,int *p1,int *p2) //Select函数,选出TREE树到a为止,权值最小且parent为0的2个节点
{
int i,j,x,y;
for(j=1;j