/* 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) { vector<int> res; if(root==NULL) return res; deque<TreeNode*>prin; prin.push_back(root); while(prin.size()) { TreeNode *tmp=prin.front(); prin.pop_front(); res.push_back(tmp->val); if(tmp->left) prin.push_back(tmp->left); if(tmp->right) prin.push_back(tmp->right); } return res; } };