还有哪里不对,改了半天
- C/C++ code
[code=C/C++]//前序s.push(root);while(!s.empty()){root=s.top();visit(root);if(root->left)s.push(root->left);else //将右子树搞进去{if(root->right)s.push(root->right);else // 右子树为空,把根弹出s.pop();}}//中序s.push(root);while(!s.empty()){root=s.top();if(root->left)s.push(root->left);elsevisit(root);//右子树if(root->right)s.push(root->right);else{s.pop();}}//后序s.push(root);while(! s.empty()){root=s.top();if(root->left)s.push(root->left);if(root->right)s.push(root->right);else{visit(root);s.pop();}}}}代码不长, 谢绝粘贴代码,我要代码的话,可以网上找,很多的
我想知道哪里错了,如何改进。
高手们帮忙看看,
[/code]
[解决办法]