Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. // @param i - index of last inserted item
  2. // @param arr - the array to be sorted (must be memset() before passed)
  3. // @return the sorted arra from <param>arr</param>
  4. void Sort(int i, int* arr)
  5. {
  6. static int N = sizeo(arr)/ sizeof(arr[0]);
  7. if (i == N)
  8. return;
  9. if (i < 1)
  10. return;
  11. if (arr[i - 1] > arr[i])
  12. {
  13. int t = arr[i - 1];
  14. arr[i - 1] = arr[i];
  15. arr[i] = t;
  16. }
  17. Sort(i - 1, arr);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement