返回首页

这里是代码,我需要为我的项目
但我不熟悉C
任何机构可以改变它的Java PLZ {S0的}


void iterativePostOrder(Node* root) {

        if (!root) {

                return;

        }

        stack<node*> nodeStack;

 

        Node* cur = root;

        while (true) {

                if (cur) {

                        if (cur->right) {

                                nodeStack.push(cur->right);

                        }

                        nodeStack.push(cur);

                        cur = cur->left;

                        continue;

                }

 

                if (nodeStack.empty()) {

                        return;

                }

 

                cur = nodeStack.top(); 

                nodeStack.pop();

 

                if (cur->right && !nodeStack.empty() && cur->right == nodeStack.top()) {

                        nodeStack.pop();

                        nodeStack.push(cur);

                        cur = cur->right;

                } else {

                        std::cout << cur->val << " ";

                        cur = NULL;

                }

        }

}
| DominoBoy

回答

评论会员:游客 时间:2012/02/07
{C}使用这个演示imgsrc=http://www.orcode.com/img/ico/smiley_frown.gif]
TorstenH
评论会员:游客 时间:2012/02/07
?你怎么知道它是有用时,你甚至不能阅读节点*是一个指针。你可以以同样的方式对待你把一个接口。您可能还需要阅读此:{A}{A2的}