还有哪里不对,改了半天
[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();}}}}