首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

请帮忙改改异常

2012-04-05 
请帮忙改改错误Swap(BinTree) *T{ BinTree*stack[100], *tempint top-1rootTif (T!NULL){top++stac

请帮忙改改错误
Swap(BinTree) *T 
{ BinTree *stack[100], *temp;
  int top=-1;
  root=T;
  if (T!=NULL)
{
  top++;
  stack[top]=T;
  while(top>-1)
  { T=stack[top];
  top--;
  if (T->child!=NULL||T->rchild!=NULL)
  { // 交换结点的左右指针
  temp=T->lchild;
  T->lchild=T->rchild;
  T->rchild=temp;
  }
  if (T->lchild!=NULL)
  { top++;
  stack[top]=T->lchild;
  }
  if (T->rchild!=NULL)
  { top++;
  stack[top]=T->rchild;
  }




main()
{ int i,j,k,l,root;
  printf("\n");
  root=CreateBinTree();
  Inorder (root);
i=CountNode (root);
  j=CountLeafs (root);
k=Depth (root);
  l=Width (root);
  printf("\n The Node ’s Number:%d",i);
  printf("\nThe Leafs’s Number:%d",j);
  printf("\nThe Depth is:%d",k);
  printf("\nThe width is:%d",l);
  Swap(root);
  Printf("\nThe swapTree is:");
Inorder(root);
}


[解决办法]
结了以前的帖子,再说。

热点排行