ZBLOG

typedef struct BiTNode { // 结点结构 TElemType data; struct BiTNode *lchild, *rchild; // 左右孩子指针 } BiTNode, *BiTree; void PreorderTraverse (BiTree T) { if (T) { printf (T->data); ...

下面是修改后的代码,修正了函数名字拼写错误、printf格式错误以及递归函数命名错误:

  1. typedef struct BiTNode { // 结点结构
  2. TElemType data;
  3. struct BiTNode *lchild, *rchild;
  4. } BiTNode, *BiTree;
  5. void PreorderTraverse(BiTree T) {
  6. if (T) {
  7. printf("%d ", T->data); // 访问根结点
  8. PreorderTraverse(T->lchild); // 遍历左子树
  9. PreorderTraverse(T->rchild); // 遍历右子树
  10. }
  11. }
  12. void InorderTraverse(BiTree T) {
  13. if (T) {
  14. InorderTraverse(T->lchild); // 遍历左子树
  15. printf("%d ", T->data); // 访问根结点
  16. InorderTraverse(T->rchild); // 遍历右子树
  17. }
  18. }
  19. void PostorderTraverse(BiTree T) {
  20. if (T) {
  21. PostorderTraverse(T->lchild); // 遍历左子树
  22. PostorderTraverse(T->rchild); // 遍历右子树
  23. printf("%d ", T->data); // 访问根结点
  24. }
  25. }
  26. int BiTNodeCount(BiTree T) {
  27. if (T == NULL)
  28. return 0;
  29. else
  30. return (BiTNodeCount(T->lchild) + BiTNodeCount(T->rchild) + 1);
  31. }
  32. int BiTLeafCount(BiTree T) {
  33. if (T == NULL)
  34. return 0;
  35. if (T->lchild == NULL && T->rchild == NULL)
  36. return 1;
  37. else
  38. return (BiTLeafCount(T->lchild) + BiTLeafCount(T->rchild));
  39. }

在修正后的代码中,修复了函数名拼写错误、printf格式错误和递归函数命名错误。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=9441

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?