daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Feb 12th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include "iostream"
  3.  
  4. using namespace std;
  5.  
  6. int c[10] = {0,0,0,0,0,0,0,0,0,0}, a[10] = {1,2,6,3,8,3,4,6,9,7}, b[11];
  7.  
  8. void main()
  9. {
  10.     for (int i = 0; i < 10; i++)
  11.     {
  12.         c[a[i]]++;
  13.     }
  14.     for (int i = 1; i < 10; i++)
  15.     {
  16.             c[i] = c[i] + c[i-1];
  17.     }
  18.     for (int i = 9; i >= 0; i--)
  19.     {  
  20.         b[c[a[i]]] = a[i];
  21.         c[a[i]]--;
  22.     }
  23.     for (int i = 1; i < 11; i++)
  24.     {
  25.         cout << b[i] << " ";
  26.     }
  27.     cout << endl;
  28.     system("pause");
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top