http://zhedahht.blog.163.com/blog/static/2541117420072199173643/
数的广度优先遍历,队列,没啥好说的。
#include <deque> struct btree { int m_value; btree *m_left; btree *m_right; }; void print_tree(btree *root) { if (root == NULL) return root; std::deque<btree*> deq; deq.push_back(root); while (deq.size()) { btree *node = deq.front(); deq.pop_front(); cout << node->m_value << ' '; if (node->m_left) deq.push_back(node->m_left); if (node->m_right) deq.push_back(node->m_right); } }