Problem D: 计数排序
[Creator : ]
Description
给你 个数,。
每个数字 范围为 。 将他们从小到大排序,然后输出。
#include <iostream>
using namespace std;
const int maxn = _____; // “桶”的数组要定义多大呢?
int n, cnt[maxn];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
// 输入 x 并把这个数字放入对应的桶中
}
for (int i = ____; ____; ______) { // 从最小的数字0到最大的数字100
for (int j = 1; _____; ______) // 输出 cnt[i] 次 i
cout << ____ << " ";
}
return 0;
}
Input
共两行,第一行为一个整数 ;
第二行为 个数字,。
对于 100% 的测试数据
, 。
Output
共一行,为 个从大到小的数字。
Sample Input Copy
5
6 7 1 2 2
Sample Output Copy
1 2 2 6 7