AcWing 3384. 构树同时输出
原题链接
简单
作者:
Jacob_fu
,
2021-06-05 21:43:54
,
所有人可见
,
阅读 429
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef struct Node{
char data;
Node * lc;
Node * rc;
}Node;
const int N = 105;
string pre;
int pos;
Node* create(){
if(pos >= pre.length()){
return NULL;
}
if(pre.at(pos) == '#')
return NULL;
Node* p = new Node();
p->data = pre.at(pos);
pos++;
p->lc = create();
cout << p->data << " ";
pos++;
p->rc = create();
return p;
}
int main(){
cin >> pre;
create();
system("pause");
return 0;
}