/*
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> result;
if(root == NULL)
return result;
deque<TreeNode*> d;
d.push_back(root);
while(d.size() != 0){
root = d.front();
result.push_back(root->val);
d.pop_front();
if(root->left != NULL)
d.push_back(root->left);
if(root->right != NULL)
d.push_back(root->right);
}
return result;
}
};