// 操作结果: 删除T中p所指结点的第i棵子树 293
294 // 因为p所指结点的地址不会改变,故p不需是引用类型 295
CSTree t; 296
int j; 297
if(T) 298
{ 299
if(i==1) 300
{ 301
t=p->firstchild; 302
p->firstchild=t->nextsibling; 303
t->nextsibling=NULL; 304
DestroyTree(t); 305
} 306
307 else //与插入算法类似。 308
{ 309
p=p->firstchild; 310
j=2; 311
while(p&&j<i) 312
{ 313
p=p->nextsibling; 314
j++; 315
} 316
if(j==i) 317
{ 318
t=p->nextsibling; 319
p->nextsibling=t->nextsibling; 320
t->nextsibling=NULL; 321
DestroyTree(t); 322
} 323
else 324
return ERROR; 325
} 326
return OK; 327
} 328
else 329
return ERROR; 330
}
void PreOrderTraverse(CSTree T,void(*Visit)(TElemType)) { //先根遍历树T。