72
73 p1->nextsibling=(CSTree)malloc(sizeof(CSNode)); 74 EnQueue(q,p1);
75 p1=p1->nextsibling;
76 p1->data=c[i];
77 }
78 p1->nextsibling=NULL; //完成结尾。 79
80 EnQueue(q,p1); //最后一个结点入队。 81
82 }
83 else
84 p->firstchild=NULL;
85 }
86 }
87 else
88 T=NULL;
89 return OK;
90 }
91
92 #define ClearTree DestroyTree
93
94 Status TreeEmpty(CSTree T)
95 { //判空。 96
97 if(T)
98 return FALSE;
99 else
return TRUE; 100
} 101
102
int TreeDepth(CSTree T) 103
104 {// 求树深度。 105
CSTree p; 106
int depth,max=0; 107
if(!T) 108
return 0; 109
if(!T->firstchild) 110
return 1; 111
for(p=T->firstchild;p;p=p->nextsibling) 112
{ 113
depth=TreeDepth(p); 114
if(depth>max) 115