Instantly share code, notes, and snippets.

Embed
What would you like to do?
void bubbleSort(int a[], int size) {
for (int i=size-2; i>=0; i--) {
bool obmen = false;
for (int j=0; j<=i; j++) {
if (a[j]>a[j+1]) {
int t = a[j];
a[j] = a[j+1];
a[j+1] = t;
obmen = true;
}
}
if (!obmen) break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment