#include <iostream>
#define null 0
struct node{
int data;
node *R;
node *L;
};
void SS(node *p){
if(p!=0){
SS(p->L) ;
printf("%d\n",p->data) ;
SS(p->R) ;
}
}
int main(int argc, char** argv) {
int x[]={5,3,9,1,6,4,8,2,7};
node *root=new node(),*p=root;
// *p=*root;
root->data=x[0];
root->L=null;
root->R=null;
for(int i=1;i<=8;i++){
int zz=1;
p=root;
// bool star=ture;
while(zz=1){
if(x[i]>p->data){
if(p->R==null){
p->R=new node();
zz=0;
}
p=p->R;
}
else{
if(p->L==null){
p->L=new node();
zz=0;
}
p=p->L;
}
}
p->data=x[i] ;
}
printf("中序\n");
SS(root) ;
return 0;
}