#define _CRT_SECURE_NO_WARNINGS #include#include using namespace std; #define FRONT 1 #define MIDDLE 2 #define BACK 3 typedef struct BiNode { char content; struct BiNode *left; struct BiNode *right;}BiNode, *BiTree; void CreateBiTree(BiTree *T) { char receive; //scanf("%c", &receive); cin >> receive; if (receive == '*') { // cout << "-"; *T = NULL; } else { // cout << receive; *T = (BiTree)malloc(sizeof(BiNode)); (*T)->content = receive; CreateBiTree(&(*T)->left); CreateBiTree(&(*T)->right); }} void show(BiTree *T, int TYPE) { if (*T == NULL) { cout << "*"; } else { switch (TYPE) { case FRONT: cout << (*T)->content ; show(&(*T)->left, TYPE); show(&(*T)->right, TYPE); break; case MIDDLE: show(&(*T)->left, TYPE); cout << (*T)->content; show(&(*T)->right, TYPE); break; case BACK: show(&(*T)->left, TYPE); show(&(*T)->right, TYPE); cout << (*T)->content; break; } }} int main() { BiTree tree ; CreateBiTree(&tree); cout << endl; show(&tree, 1); system("pause"); return 0;}