/**
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
class Solution {
public:
void preOrder(TreeNode* root,vector<int> &ans){
if(root == nullptr) return;
ans.insert(ans.end(), root->val);
preOrder(root->left, ans);
preOrder(root->right, ans);
}
void postOrder(TreeNode* root,vector<int> &ans){
if(root == nullptr) return;
postOrder(root->left, ans);
postOrder(root->right, ans);
ans.insert(ans.end(), root->val);
}
void midOrder(TreeNode* root,vector<int> &ans){
if(root == nullptr) return;
midOrder(root->left, ans);
ans.insert(ans.end(), root->val);
midOrder(root->right, ans);
}
/**
*
* @param root TreeNode类 the root of binary tree
* @return int整型vector<vector<>>
*/
vector<vector<int> > threeOrders(TreeNode* root) {
vector<vector<int>> ans(3);
preOrder(root, ans[0]);
midOrder(root, ans[1]);
postOrder(root, ans[2]);
return ans;
}
};