├─◆ 狼盟首页 > 查看贴子 > 详细信息
楼主
高手过来看:二叉树的先序遍历非递归算法(怎样改编为程序在VC++里通过啊!!)
在一本参考书里看到下面的算法,可是本人很久没弄C++了,不知道怎样改才能在VC++里通过编译啊。明天就要上机实习了,哪位大虾能帮帮小弟啊?#define maxsize 100typedef struct{ Bitree Elem[maxsize]; int top;}SqStack;void PreOrderUnrec(Bitree t){ SqStack s; StackInit(s); p=t; while (p!=null || !StackEmpty(s)) { while (p!=null) //遍历左子树 { visite(p->data); push(s,p); p=p->lchild; }//endwhile if (!StackEmpty(s)) //通过下一次循环中的内嵌while实现右子树遍历 { p=pop(s); p=p->rchild; }//endif }//endwhile }//PreOrderUnrec