/**
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
class Solution {
public:
/**
*
* @param root TreeNode类 the root of binary tree
* @return int整型vector<vector<>>
*/
vector<vector<int> >a;
void Preorder(TreeNode*root){
if(root!=NULL){
cout<<root->val<<' ';
a[0].push_back(root->val);
Preorder(root->left);
Preorder(root->right);
}
}
void InOrder(TreeNode*root){
if(root!=NULL){
InOrder(root->left);
cout<<root->val<<' ';
a[1].push_back(root->val);
InOrder(root->right);
}
}
void BackOder(TreeNode*root){
if(root!=NULL){
BackOder(root->left);
BackOder(root->right);
cout<<root->val<<' ';
a[2].push_back(root->val);
}
}
vector<vector<int> > threeOrders(TreeNode* root) {
a.resize(3);
// write code here
Preorder(root);
cout<<endl;
InOrder(root);
cout<<endl;
BackOder(root);
return a;
}
};