这个简单
#include <queue> void PrintFromTopToBottom(BinaryTreeNode* pRoot) { if (pRoot == NULL) return; std::queue<BinaryTreeNode *> queueData; queueData.push(pRoot); while (!queueData.empty()) { BinaryTreeNode *tempNode = queueData.front(); printf("%d ", tempNode->m_nValue); queueData.pop(); if (tempNode->m_pLeft != NULL) queueData.push(tempNode->m_pLeft); if (tempNode->m_pRight != NULL) queueData.push(tempNode->m_pRight); } }