/** * 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<int> a,b,c; vector<vector<int> > threeOrders(TreeNode* root) { // write code here vector<vector<int>> ans; preOrder(root); inOrder(root); postOrder(root); ans.push_back(a); ans.push_back(b); ans.push_back(c); return ans; } void preOrder(TreeNode* root) { if(root==NULL) return; a.push_back(root->val); preOrder(root->left); preOrder(root->right); } void inOrder(TreeNode* root) { if(root==NULL) return; inOrder(root->left); b.push_back(root->val); inOrder(root->right); } void postOrder(TreeNode* root) { if(root==NULL) return; postOrder(root->left); postOrder(root->right); c.push_back(root->val); } };