add comment

This commit is contained in:
xusun000
2021-11-29 17:25:25 +08:00
parent 57fbb00ad6
commit 3f27972d34
3 changed files with 13 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
#include<stdio.h>
#include <stdlib.h>
typedef struct node {
char data[10];
struct node* left, * right;
@@ -11,15 +12,16 @@ void midQuation(BTree* T) {
bool flag = false;
flag = (t == '+' || t == '-' || t == '*' || t == '/');
if (flag)printf("(");
if (T->left != NULL)midQuation(T->left);
for (int i = 0;T->data[i] != '\0';i++) {
printf("%c", T->data[i]);
}
if (T->right != NULL)midQuation(T->right);
if (T->left != NULL)midQuation(T->left);//左子树递归
printf("%c", T->data[0]);//打印当前节点
if (T->right != NULL)midQuation(T->right);//右子树递归
if (flag)printf(")");
}
}
/**
* 创建二叉树
*/
void createTree(BTree* node, char c[], int pos, int length) {
if (pos < length) {//填入数据
node->data[0] = c[pos];