#include <stdio.h> #include<stdlib.h> typedef struct BinaryTreeNode { char val; struct BinaryTreeNode*left; struct BinaryTreeNode*right; }BTNode; BTNode* BinaryTreeCreat(char*arr,int*pi) { if(arr[*pi] == '#') { (*pi)++; return NULL; } else { BTNode*node = (BTNode*)malloc(sizeof(BTNode)); node->val = arr[*pi]; (*pi)++; node->left = BinaryTreeCreat(arr,pi); node->right = BinaryTreeCreat(arr,pi); return node; } } void InOrder(BTNode*root) { if (root == NULL) { return; } else { InOrder(root->left); printf("%c ", root->val); InOrder(root->right); } } int main() { char arr[100]; while(scanf("%s",arr) != EOF) { int i = 0; BTNode* root = BinaryTreeCreat(arr,&i); InOrder(root); } return 0; }