#include<stdio.h> #include<stdlib.h> typedef struct TreeNode{ struct TreeNodeleft; struct TreeNoderight; char data; }TreeNode;
TreeNode* TreeCreate(chara,inti) { if(a[*i]=='#') { (*i)++; return NULL; }
TreeNode*root=(TreeNode*)malloc(sizeof(TreeNode*));
root->data=a[(*i)++];
root->left=TreeCreate(a,i);
root->right=TreeCreate(a,i);
return root;
}
void InOrder(TreeNoderoot) { if(root==NULL) { return; } InOrder(root->left); printf("%c ",root->data); InOrder(root->right); } int main() { char a[100]; scanf("%s",a); //创建二叉树 int i=0; TreeNoderoot=TreeCreate(a,&i); InOrder(root); }