首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

Huffman树的一段代码,不知道错哪了

2012-09-28 
Huffman树的一段代码,不知道哪里错了请指教Huffman树的一段代码,修改过便于发贴C/C++ code#include stdio

Huffman树的一段代码,不知道哪里错了请指教
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 申请空间

热点排行