/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
struct TreeNode* invertTree(struct TreeNode* root){
if(root == NULL)
return root;
//创建翻转后的二叉树的首节点;
struct TreeNode* iT=(struct TreeNode*)
malloc(sizeof(struct TreeNode));
iT->val = root->val;
if(root->left != NULL)
iT->right = invertTree(root->left);
else
iT->right = NULL;
if(root->right != NULL)
iT->left = invertTree(root->right);
else
iT->left = NULL;
return iT;
}