計算二叉樹的層數
int getLevel(BinaryTree root){
int last, level, front, rear;
last = level = 0;
front = rear = -1;
TreeNode *data[MAXSIZE]; //佇列足夠大
TreeNode *p = root;
data[++rear] = p; //根結點入隊
while(front < rear){
p = data[++front];
if(p->lChild){
data[++rear] = p->lChild
}
if(p->rChild){
data[++rear] = p->rChild;
}
if(front == rear){
level ++;
last = rear;
}
}
return level;
}