#include<stdio.h>
#include<stdlib.h>
#include<stack>
using namespace std;
typedef struct node{struct node*lchild;struct node*rchild;char data;
}Node,*Bit;Bit creat(){//先序创建
char b;
int t;
scanf("%c",&b);
t=getchar();//吸收空格 if(b=='#')return NULL;else{Bit tree=(Bit)malloc(sizeof(Node));tree->data=b;printf("please input %c lefttree:",b);tree->lchild=creat();printf("please input %c righttree:",b); tree->rchild=creat();return tree;}
}
void fei(Node*tree){//先序 stack<Bit>s;Node*cur=tree;if(cur==NULL)return;while(!s.empty()||cur!=NULL){if(cur!=NULL){printf("%c ",cur->data);s.push(cur);cur=cur->lchild;}else{cur=s.top();s.pop();cur=cur->rchild;}
}
}int main(){
Bit tree;printf("please input root data:\n");
tree=creat();
printf("success_init_tree\n");
fei(tree);
}