PAT1064

来源:互联网 发布:淘宝黑车技术的原理 编辑:程序博客网 时间:2024/05/21 14:02
#include<stdio.h>#include<algorithm>using namespace std;const int maxn=1010;int input[maxn];int tree[maxn];int n,index=1;void inorder(int root){if(root>n)return ;inorder(root*2);tree[root]=input[index++];inorder(root*2+1);} int main(){//freopen("in.txt","r",stdin);scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&input[i]);sort(input,input+n+1);inorder(1);for(int i=1;i<n;i++)printf("%d ",tree[i]);printf("%d\n",tree[n]);return 0;}

0 0
原创粉丝点击