Skip to content

Instantly share code, notes, and snippets.

@gamalielhere
Last active June 21, 2018 03:16
Show Gist options
  • Save gamalielhere/45fdf1e81a9b45e627caf9bba51379a1 to your computer and use it in GitHub Desktop.
Save gamalielhere/45fdf1e81a9b45e627caf9bba51379a1 to your computer and use it in GitHub Desktop.
Bubble Sort for C++
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