#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#define ll long long
#define elif else if
using namespace std;
int main()
{
char a;
char array[1026] = { 0 };
int p = 2;
cin >> a;
while (cin >> a)
{
if (a == '#')
{
array[p] = a;
if (p % 2 == 0)
++p;
else
{
do
{
p = (p - 1) / 2;
} while (p % 2 == 1);
++p;
}
}
else
{
array[p] = a;
p *= 2;
}
}
cout<<array[2];
for (int i = 3; i < 1026; ++i)
{
if (array[i] == '#' || array[i] == 0)
;
else
cout << ","<< array[i] ;
}
return 0;
}
东华大学oj二叉树:层次遍历
最新推荐文章于 2024-10-17 21:38:17 发布