Huffman树的一段代码,不知道错哪了
Huffman树的一段代码,不知道哪里错了请指教
Huffman树的一段代码,修改过便于发贴
用g++编译,但老是就报个segmantaion fault 不知所云啊,还请各位给看下!
------解决方案--------------------
int main(){
;//这里怎么有个;
int weight=0;
------解决方案--------------------
HNode *hNode; 是个指针 得new 申请空间
Huffman树的一段代码,修改过便于发贴
- C/C++ code
#include <stdio.h> #include <vector> using namespace std; struct HuffmanNode{ int weight; int isLeaf; struct HuffmanNode *parent; bool isUsed; }; typedef struct HuffmanNode HNode; vector<HNode*> myQueue; int main(){ ; int weight=0; for(int i=0;i<5;i++){ HNode *hNode; hNode->weight=weight; hNode->isLeaf=true; hNode->isUsed=false; hNode->parent=NULL; myQueue.push_back(hNode); } printf("queue size:%d\n",myQueue.size()); return 0; }
用g++编译,但老是就报个segmantaion fault 不知所云啊,还请各位给看下!
------解决方案--------------------
int main(){
;//这里怎么有个;
int weight=0;
------解决方案--------------------
HNode *hNode; 是个指针 得new 申请空间