|
楼主 |
发表于 2020-5-10 21:54:47
From FishC Mobile
|
显示全部楼层
#include <iostream>
#include <fstream>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;
typedef char Elemtype;
typedef struct Node{
char code[26];
Elemtype data;
double weight;
int left ,right,parent;
}Node,*HuffmanTree;
void createHuffmanTree(HuffmanTree &HfTree ,int size);
void bottonToUp(HuffmanTree &HfTree,int size);
int number;
stack<int> s;
void frame()
{
cout<<"1-----创建26个字母表使用频率的哈夫曼树"<<endl;
}
int main(void)
{
frame();
int size=26;
cout<<"请输入节点数"<<endl;
cin>>size;
if(size<=1)
{
cout<<"节点数目不足于构建哈夫曼树"<<endl;
return 0;
}
number=2*size-1;
HuffmanTree HfTree=new Node[number+1];
createHuffmanTree(HfTree,size);
// for(int i=1;i<=number;i++)
//cout<<HfTree[i].weight;
bottonToUp(HfTree,size);
}
int a[51]={0}; |
|