int BTLC(BiTree Tint *c)//對二叉樹T的結點計數
{if(T)
{*c++;
BTLC(T>lchild&c); //統計左子樹結點
BTLC(T>rchild&c); //統計右子樹結點
} }//結束Count調用時*c=
int Count(CSTree t)//統計以孩子兄弟鏈表表示的樹的葉子結點個數
{if(t==null) return();
else if(t>firstlchild==null) //左子女為空結點必為葉子
return(+Count(t>nextsibling)) //(葉子)+兄弟子樹上的葉子結點
else return(Count(t>firstchild)+Count(t>nextsibling));//子女子樹+兄弟子樹
}//Count
void Count(BiTree btint *n*n) //統計二叉樹bt上葉子結點數n和非葉子結點數n
{if(bt)
{if (bt>lchild==null && bt>rchild==null) *n++//葉子結點
else *n++; //非葉結點
Count(bt>lchild&n&n);
Count(bt>rchild&n&n);
} }//結束 Count
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/23711.html