# ZJ d190
[題目點我](https://zerojudge.tw/ShowProblem?problemid=d190)
:::success
當資料 只會有正數且可能會有重複時,Counting Sort是最快的
:::
```cpp=
#include <bits/stdc++.h>
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
int main() {
while (true){
int n;
cin >> n;
if (n==0)break;
vector<int> a(n);
for (int i{0} ;i<n;i++)cin >> a[i];
int mx=*max_element(a.begin(), a.end());
vector<int> arr(mx+1,0);
for (auto i:a) arr[i]++;
for (int i{0},j{0};i<=mx;i++){
while (arr[i]--) a[j++]= i;
}
for (auto i:a)cout << i<<" ";
cout <<endl;
}
}
```