二叉树前序遍历 ``` c /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ /** * Return an array of size *returnSize. * Note: The returned array must be malloced, assume caller calls free(). */ int* preorderTraversal(struct TreeNode* root, int* returnSize) { int i = 0; //int *arr = (int *)malloc(100*sizeof(int)); if(root) { returnSize[i++] = root->val; preorderTraversal(root->left, returnSize); preorderTraversal(root->right, returnSize); } return returnSize; } ```