/**
 * 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> > threeOrders(TreeNode* root) {
        vector<vector<int>> res;
        auto q = root;
        res.push_back(pre(q));
        res.push_back(mid(q));
        res.push_back(pos(q));
        return res;

    }
    vector<int > ans1; 
    vector<int> pre(TreeNode* root){
        if(root==nullptr) return ans1;
            auto left = root->left; // 此处不需要while(root),当递归到根节点时候,会自动return ans1;
            auto right = root->right;
            ans1.push_back(root->val);
            pre(left);
            pre(right);
        return ans1;
    }
    vector<int> ans2;
    vector<int> mid(TreeNode* root){
        if(root==nullptr) return ans2;
            auto left = root->left;
            auto right = root->right;
            mid(left);
            ans2.push_back(root->val);
            mid(right);
        return ans2;
    }
    vector<int> ans3;
    vector<int> pos(TreeNode* root){
        if(root==nullptr) return ans3;
            auto left = root->left;
            auto right = root->right;
            pos(left);
            pos(right);
            ans3.push_back(root->val);
        return ans3;
    }
};