当前位置: 代码迷 >> 综合 >> POJ2255(二叉树遍历)
  详细解决方案

POJ2255(二叉树遍历)

热度:39   发布时间:2024-01-18 18:45:14.0

待学完树补。

#include <iostream>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
deque<int> q;
const int maxn = 30+ 6;
char a[maxn];
char b[maxn];
void build(int n, char a[], char b[]) {if(n <= 0) return;int p = strchr(b,a[0]) - b;build(p,a+1,b);build(n-p-1,a+p+1,b+p+1);cout<<a[0];
}
int main() {while (cin >> a >> b) {int len = strlen(a);build(len,a,b);cout << endl;}}

 

  相关解决方案