Advertisement
Garey

Test Bubble Sort

Dec 18th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. void BubbleSort(int Arr[], int size)
  2. {  
  3.     bool swapped;
  4.     do {
  5.         swapped = false;
  6.         for (int j=0;j<size-1;j++)
  7.             if (Arr[j]>Arr[j+1]) {
  8.                 int temp = Arr[j];
  9.                 Arr[j] = Arr[j+1];
  10.                 Arr[j+1] = temp;
  11.                 swapped = true;
  12.             }
  13.     } while (swapped);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement