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