#include<algorithm>#include<iostream>#include<map>#include<math.h>#include<queue>#include<set>#include<stack>#include<stdio.h>#include<string.h>#include<string>#include<vector>#defineemplace_backpush_back#definepbpush_backusingnamespace std;typedeflonglong LL;constint mod =1e9+7;constdouble eps =1e-6;constint inf =0x3f3f3f3f;constint N =2e5+10;int a[N];int c[N];voidssort(int a[],int f,int t){if(t-f<=0){//cout << a[f]<<"*"<< endl;return;}int mid =(f + t)/2;ssort(a,f,mid);ssort(a,mid+1,t);int i = f, j = mid +1;int num = f;while(i <= mid && j <= t){if(a[i]< a[j]){
c[num++]= a[i];
i++;}else{
c[num++]= a[j];
j++;}}while(i <= mid){
c[num++]= a[i++];}while(j <= t){
c[num++]= a[j++];}for(int i = f; i <= t; i++){
a[i]= c[i];}// for (int i = 1; i <= t;i++)// {// cout << a[i] << "#";// }// cout << endl;return;}intmain(){int n;
cin >> n;for(int i =1; i <= n; i++){
cin >> a[i];}ssort(a,1,n);for(int i =1; i <= n; i++){
cout << c[i]<< endl;}return0;}
快速排序
voidksort(int a[],int l,int r){if(l>=r){return;}int k = l;int u = r;for(int i = l+1; i <= r;i++){if(a[i]<a[l]){
c[k++]= a[i];}else{
c[u--]= a[i];}}
c[k]= a[l];for(int i = l; i <= r;i++){
a[i]= c[i];}ksort(a, l, k);ksort(a, k +1, r);return;}
堆排序
冒泡排序
voidmsort(int*a,int l,int r){for(int i = l; i <= r; i++){for(int j = l; j < r;j++){if(a[j]>a[j+1]){swap(a[j], a[j+1]);}}}}
桶排序
voidtsort(int*a,int l,int r){memset(c,0,sizeof(c));int maxx =0;int minn =-1000000;for(int i = l; i < r;i++){
c[a[i]]++;
maxx =max(maxx, a[i]);
minn =min(minn, a[i]);}for(int i = minn; i <= maxx;i++){for(int i =0; i <= c[i];i++){
cout << i << endl;}}return;}