那位大虾能帮我看看这个程序阿~~~

来源:百度知道 编辑:UC知道 时间:2024/05/10 11:52:17
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

int i =0;

typedef struct treenode /*树节点结构体定义*/
{
int data;
struct treenode *lchild;
struct treenode *rchild;
}node;

typedef struct queuenode /*队列节点结构体定义*/
{
node* info;
struct queuenode *next;
}qnode;

typedef struct /*将头尾指针封装在一起*/
{
qnode *front;
qnode *rear;
}lqueue;

lqueue * initlqueue (lqueue *q) /*初始化一个空队列*/
{
q = (lqueue*)malloc(sizeof (lqueue));
if (q)
{
q ->front = 0;
q ->rear = 0;
}
return q;
}

void destroylqueue (lqueue *q) /*销毁队列*/
{
qnode *p;
if (q)
{
while (q ->front)
{
p = q ->front;
q ->front = q ->front ->next;
free (p);
}
free (q);
}
q = 0;
}

int isempty (lq

你在哪编译的?我在VC++6.0里编译没有问题啊?
你试着把node *p = root;放到前面一行~~先声明,再做q的定义.
lqueue *q;
node *p = root;
q = initlqueue (q);

dequeue函数前面多写了个breadthfirst函数,不知道是不是这个原因.反正在我机子上把这个多余的函数去掉就OK了.