运行结果正确
其实也不难,牢牢记住栈是用来放右节点的就行了。
#include <stdio.h>
#include <stdlib.h>
typedef struct tree_node{
int val;
struct tree_node *left;
struct tree_node *right;
}tree;
//top是为非递归的栈提供的
int top=-1;
//创建新树
int creat_tree(tree **t){
int val;
scanf("%d",&val);
if(val==-1){
*t=NULL