标签:pop roo nod oid 二叉树遍历 treenode ack div val
void PreOrder(TreeNode *root) { TreeNode *p = root; stack<TreeNode*> s; while (!s.empty() || p) { while (p) { cout << p->val << endl; s.push(p); p = p->left; } if (!s.empty()) { p = s.top(); s.pop(); p = p->right; } } }
标签:pop roo nod oid 二叉树遍历 treenode ack div val
原文地址:http://www.cnblogs.com/zhwcs/p/7543666.html