This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 10;
int a[] = {1, 2, 5, 4, 3, 2};
int b[N];
int mx, mi = INF;
int main() {
// C++求整数数组长度的办法
int len = sizeof(a) / 4;
// sizeof(int);
//最大值,最小值
for (int i = 0; i < len; i++)
mx = max(mx, a[i]), mi = min(mi, a[i]); //最大值:5,最小值:1
//放入桶
for (int i = 0; i < len; i++) b[a[i]]++;
//排序结果
for (int i = mi; i <= mx; i++) {
for (int j = 1; j <= b[i]; j++)
printf("%d ", i);
}
return 0;