Last active
June 21, 2018 03:16
-
-
Save gamalielhere/45fdf1e81a9b45e627caf9bba51379a1 to your computer and use it in GitHub Desktop.
Bubble Sort for C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void bubbleSortArray(int array[], int size) { | |
bool swap; | |
int temp; | |
do { | |
swap = false; | |
for (int count = 0; count < (size - 1); count ++) { | |
if (array[count] > array[count + 1]) { | |
temp = array[count]; | |
array[count] = array[count + 1]; | |
array[count + 1] = temp; | |
swap = true; | |
} | |
} | |
} while (swap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment