/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { public: vector<int> PrintFromTopToBottom(TreeNode* root) { queue<TreeNode*> Q; vector<int> output; if(root) Q.push(root); while(!Q.empty()) { TreeNode* t=Q.front(); output.push_back(t->val); Q.pop(); if(t->left) Q.push(t->left); if(t->right) Q.push(t->right); } return output; } };