1 class Solution{ 2 public : 3 vector<int> PrintFromTopToBottom(TreeNode* root){ 4 vector<int> vec; 5 queue<TreeNode*> Q; 6 if(root==NULL) return vec; 7 Q.push(root); 8 while(!Q.empty()) 9 { 10 TreeNode* p = Q.front(); 11 Q.pop(); 12 vec.push_back(p->val); 13 if(p->left) 14 Q.push(p->left); 15 if(p->right) 16 Q.push(p->right); 17 } 18 return vec; 19 } 20 };