碧落的海
以下内容是手打的,可能有小错递归:void swap(Bitree *t){if (!t)return;Bitree *temp = t->left;t->left = t->right;t->right = temp;swap(t->left);swap(t->right);}非递归:void swap(Bitree *t){//个人喜欢以层次为顺序遍历if (!t)return;Bitree *queue[1000]; //这种方式总结点数不能超过1000int count = 0, head = 0;queue[count++] = t;for (;count > head; head ++){Bitree *first = queue[head];Bitree *temp = first->left;first->left = first->right;first->right = temp;if (first->left)queue[count++] = first->left;if (first->right)queue[count++] = first->right;}}