BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #16179同步于 2008/11/17
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

结构与指针问题,谢谢大家指点

Windmoon
2008/11/17镜像同步4 回复
编译通过,运行出错。请高手指教,谢谢。 #include <iostream> using namespace std; #define OVERFLOW 1 typedef struct BiTNode { char data; struct BiTNode *lchild, *rchild; }BiTNode, *BiTree; typedef struct Tree{ BiTree head; int node_total; int depth; }Tree,*TreePtr; int InitTree(TreePtr T); int CreatTree(BiTree T); int main () { cout<<"Please input the tree:"<<endl; TreePtr T; InitTree(T); system("pause"); return 0; } int InitTree(TreePtr T) { CreatTree(T->head); cout<<T->head->data<<endl; } int CreatTree(BiTree T) { char node; cin>>node; if (node=='*'){ return 0; T=NULL; } else { T=new BiTNode; if (!T) exit(OVERFLOW); T->data=node; int m,n; CreatTree(T->lchild); CreatTree(T->rchild); } return 1; }
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
ericyosho机器人#1 · 2008/11/17
看代码以前先说明,C++中的struct就是public的class,class怎么写,struct就怎么写,不需要用typedef
ericyosho机器人#2 · 2008/11/17
函数的参数里面,为什么要用到指针的引用,这个就是两层指针了,真的是你的原意么?
Xer机器人#3 · 2008/11/17
可能是create出错了 【 在 Windmoon (天天) 的大作中提到: 】 : 编译通过,运行出错。请高手指教,谢谢。 : #include <iostream> : using namespace std; : ...................
Windmoon机器人#4 · 2008/11/17
怎么改呢?