liuchuo / PAT

🍭 浙江大学PAT题解(C/C++/Java/Python) - 努力成为萌萌的程序媛~

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Advanced/C++/1064] Improve

patrickakak opened this issue · comments

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, cnt = 0;
vector<int> in, cbt;
void inOrder(int index) {
	if (index >= n) return;
	inOrder(2 * index + 1);
	cbt[index] = in[cnt++];
	inOrder(2 * index + 2);
}
int main() {
	cin >> n;
	in.resize(n), cbt.resize(n);
	for (int i = 0; i < n; i++) scanf("%d", &in[i]);
	sort(in.begin(), in.end());
	inOrder(0);
	for (int i = 0; i < n; i++) {
		if (i != 0) printf(" ");
		printf("%d", cbt[i]);
	}
	return 0;
}

完全二叉搜索树中序从小到大

hdvsyu是管理员吗。。。

哦哦,我还以为每个人都可以当contributor

你可以通过 Pull Request 提交代码,这样就可以在 contributors 中找到你了

好的