好久没做题了,这么谁都过不去《求助》
  • 板块UVA11462 Age Sort
  • 楼主_Empty
  • 当前回复7
  • 已保存回复7
  • 发布时间2021/3/18 15:36
  • 上次更新2023/11/5 01:55:44
查看原帖
好久没做题了,这么谁都过不去《求助》
379940
_Empty楼主2021/3/18 15:36

code:

#include <bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int> >q;
int n, x;
int main() {
	while (cin>> n) {
		if (n== 0) return 0;
		for (int i= 1; i<= n; i++) {
			cin>> x;
			q.push(x); 
		}
		for (int i= 1; i<= n; i++) {
			cout<< q.top() << ' ';
			q.pop();
		}
		cout<< endl;
	}
	return 0;
}
2021/3/18 15:36
加载中...