?? 6.43.c
字號:
6.43③ 編寫遞歸算法,將二叉樹中所有結點的
左、右子樹相互交換。
要求實現下列函數:
void Exchange(BiTree &bt);
/* Exchange the left and right leaves of */
/* bitree whose root node is bt */
二叉鏈表類型定義:
typedef struct BiTNode {
TElemType data;
BiTNode *lchild, *rchild;
} BiTNode, *BiTree;
void Exchange(BiTree &bt)
/* Exchange the left and right leaves of */
/* bitree whose root node is bt */
{
struct BiTNode *temp;
temp=bt->rchild;
bt->rchild=bt->lchild;
bt->lchild=temp;
if(bt->rchild) Exchange(bt->rchild);
if(bt->lchild) Exchange(bt->lchild);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -