二叉树遍历(算法)


二叉树遍历

原题
思路:树的遍历
题意:已知二叉树的前序遍历(带有空节点位置)求中序遍历
一边“建树”,一边输出

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

void build()
{
    char ch = getchar();
    if(ch == '#')
        return ;

    build();
    cout << ch << ' ';
    build();
}

int main()
{
    build();
    return 0;
}

Author: 寒风渐微凉
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source 寒风渐微凉 !
 Previous
Next 
  TOC