Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void bubble_sort(int n, int i, int z, int array[])
  4. {
  5. void bubble(int n, int i, int z, int array[]);
  6. if (z < n)
  7. {
  8. bubble(n, 0, ++z, array);
  9. }
  10. else printf("%d\n", array[n]);
  11. }
  12.  
  13. void bubble(int n, int i, int z, int array[])
  14. {
  15. if (i < n)
  16. {
  17. if (array[i] > array[i + 1])
  18. {
  19. int aux = array[i];
  20. array[i] = array[i + 1];
  21. array[i + 1] = aux;
  22. }
  23. bubble(n, ++i, z, array);
  24. }
  25. else bubble_sort(n, i, z, array);
  26. }
  27.  
  28. void loop(int n, int i, int array[])
  29. {
  30. scanf("%d", &array[i]);
  31. if (array[i] != 0)
  32. {
  33. loop(i, ++i, array);
  34. }
  35. else bubble_sort(n, 0, 0, array);
  36.  
  37. }
  38.  
  39. int main ()
  40. {
  41. int n;
  42. int array[n];
  43. loop(n, 0, array);
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement