Home > Back-end >  Don't understand, ask: learning data structure, according to the order before the book creates
Don't understand, ask: learning data structure, according to the order before the book creates

Time:09-23

Don't know how to create function wrong

CodePudding user response:

Did not include the header file? Can post the complete code

CodePudding user response:

The
reference 1/f, Simple, Soft reply:
did not include the header file? Can post the full code to know

#include
#include

Typedef struct BiTNode {
Char data;
Struct lchild BiTNode * and * rchild;
} BiTNode, * BiTree;

Void CreateBiTree (BiTree & amp; T) {//sequence traversal first create a binary list
Char ch;
Printf (" please input node values (#) : ");
The scanf (" % c ", & amp; Ch);
If (ch=='#') T=NULL;
The else
{
T=(BiTree) malloc (sizeof (BiTNode));
T - & gt; Data=https://bbs.csdn.net/topics/ch;
CreateBiTree (T - & gt; Lchild);
CreateBiTree (T - & gt; Rchild);
}
}

Void PreOrderTraverse (BiTree T) {//preorder traversal recursive algorithm of binary tree T
If (T) {
Printf (" % c ", T - & gt; The data);
PreOrderTraverse (T - & gt; Lchild);
PreOrderTraverse (T - & gt; Rchild);
}
}

Void InOrderTraverse (BiTree T) {//sequence in the recursive algorithm of traversing binary tree T
If (T) {
InOrderTraverse (T - & gt; Lchild);
Printf (" % c ", T - & gt; The data);
InOrderTraverse (T - & gt; Rchild);
}
}

Void PostOrderTraverse (BiTree T) {//sequence in the recursive algorithm of traversing binary tree T
If (T) {
PostOrderTraverse (T - & gt; Lchild);
PostOrderTraverse (T - & gt; Rchild);
Printf (" % c ", T - & gt; The data);
}
}

Void main () {
BiTree T;
CreateBiTree (& amp; T);
Printf (" sequence traversal before: ");
PreOrderTraverse (T);
Printf (" sequence traversal in: ");
InOrderTraverse (T);
Printf (" sequence traversal: after ");
PostOrderTraverse (T);
}

CodePudding user response:

You this is a c or c + +, pure c is not support for reference, you changed to * T

CodePudding user response:

reference 3 floor is Simple - Soft reply:
you is this a c or c + +, pure c is not support for reference, you changed to * T

Pure CCCCCC

CodePudding user response:

So can't use & amp; reference

CodePudding user response:

Simple reference 5 floor - Soft reply:
so cannot use & amp; Reference

Ok, thank you
  • Related