You are viewing a single comment's thread. Return to all comments →
using namespace std;
void countingSort(int a[], int n) { int freq[100] = {0}; for (int i = 0; i < n; i++) { freq[a[i]]++; } for (int i = 0; i < 100; i++) { cout << freq[i] << " "; } cout << endl; } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } countingSort(a, n); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 1
You are viewing a single comment's thread. Return to all comments →
include
using namespace std;
void countingSort(int a[], int n) { int freq[100] = {0}; for (int i = 0; i < n; i++) { freq[a[i]]++; } for (int i = 0; i < 100; i++) { cout << freq[i] << " "; } cout << endl; } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } countingSort(a, n); return 0; }