mirror of
https://github.com/xusun0623/exam_code_for_408.git
synced 2026-02-09 21:25:17 +08:00
add comment
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user