二叉排序树:
http://www.patest.cn/contests/pat-a-practise/1064
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std; int ans[]; int cnt = ; void inoder(vector<int> vv,int x,int n)
{
if(*x <= n)
{
inoder(vv,*x,n);
}
ans[x] = vv[cnt++];
if(*x + <= n)
{
inoder(vv,*x +,n);
}
} int main()
{
int n,tem;
vector<int> vv;
cin >> n;
int i = n;
while(i--)
{
cin >> tem;
vv.push_back(tem);
}
sort(vv.begin(),vv.end());
inoder(vv,,n);
bool fir = ;
for(i = ; i <= n ;++i)
{
if(fir)
{
fir = ;
cout << ans[i];
}
else
{
cout << " " << ans[i];
}
}
cout << endl;
return ;
}