Advertisement
TheDuliX_

Untitled

Sep 13th, 2021
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void bubblesort(int a[]) {
  5. for (int i = 0; i < 10; i++)
  6. {
  7. for(int j = 0; j < (10 - i - 1); j++)
  8. {
  9. if(a[j] > a[j+1])
  10. {
  11. int b = a[j];
  12. a[j] = a[j+1];
  13. a[j+1] = b;
  14. }
  15. }
  16. }
  17.  
  18. }
  19.  
  20. int main() {
  21. int array[10];
  22. int size;
  23. cout << "Unesite 10 brojeva: ";
  24. for (int i = 0; i < 10; i++)
  25. {
  26. cin >> array[i];
  27. }
  28. cout << "Pre sortiranja " << endl;
  29. for (int i = 0; i < 10; i++) {
  30. cout << array[i] << " ";
  31. }
  32.  
  33. bubblesort(array);
  34.  
  35. cout << "Sortirano: ";
  36. for (int i = 0; i < 10; i++) {
  37. cout << array[i] << " ";
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement