Advertisement
Guest User

Counting Sort 2

a guest
Oct 26th, 2014
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n, in, temp;
  9. cin >> n;
  10. int arr[n];
  11. for(int i = 0; i < n; i++)
  12. {
  13. cin >> arr[i] ;
  14. }
  15. for(int i=0; i<n ;i++)
  16. {
  17. for(int j=0;j<n;j++)
  18. {
  19. if(arr[i] < arr[j])
  20. {
  21. temp = arr[i];
  22. arr[i] = arr[j];
  23. arr[j] = temp;
  24.  
  25.  
  26. }
  27.  
  28.  
  29. }
  30.  
  31.  
  32.  
  33. }
  34.  
  35. for(int i = 0; i < n; i++){
  36. cout << arr[i] << " ";
  37. }
  38. cout << endl;
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement