BTREE CreatBT( ) //按邏輯結構建立二叉樹,依次輸入結點、父結點、標號、權值
{
cout<<"請按邏輯結構輸入二叉樹"<<endl;
Bnode p;
Squeue q;
BTREE root, s;
root=new node;
root=NULL;
Makenull(q);
cin>>p.data>>p.parent>>p.tag>>p.weight;
while (p.data!='0')
{
s=new node;
s->data=https://bbs.csdn.net/topics/p.data;
s->weight=p.weight;
s->lchild=s->rchild=NULL;
q.rear=(q.rear+1)%100;
q.ele[q.rear]=s;
if (p.parent=='0')
root=s;
else
{
while (q.rear+1%100!=q.front&&q.ele[q.front]->data!=p.parent)
q.front=(q.front+1)%100;
if (q.ele [q.front]->data=https://bbs.csdn.net/topics/=p.parent)
{
if (p.tag=='L')
q.ele[q.front]->lchild=s;
else
q.ele[q.front]->rchild=s;
}
}
cin>>p.data>>p.parent>>p.tag>>p.weight;
}
return root;
}
這是其中建立二叉樹的演算法。
除錯時提示 if (q.ele [q.front]->data=https://bbs.csdn.net/topics/=p.parent) 這一行
expression cannot be evaluated
0xc0000005:Access Violation
symbol"this"not fount 什么的
因為我本身不是這個專業的- -所以看不太懂,大概是q.ele [q.front]沒有初始化么?
想請問一下這個要怎么改呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/107098.html
標籤:基礎類
