📄 4.cpp
字号:
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define null 0
typedef struct node
{ char data;
node *lchild;
node *rchild;
}* bitree;
int setup(bitree &t)
{char ch=' ';
scanf("%c",&ch);
if(ch==' ')t=null;
else{
if(!(t=(node *)malloc(sizeof(node))))return 0;
t->data=ch; //建立根节点
printf("%c",t->data);
setup(t->lchild);//建立左子树
setup(t->rchild);//建立右子树
}
return 1;
}
void main()
{bitree t=null;
printf("输入数值:");
setup(t);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -