Skip to content

Instantly share code, notes, and snippets.

@EugenyB
Created November 26, 2014 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EugenyB/6818c61126ec36e1fdcb to your computer and use it in GitHub Desktop.
Save EugenyB/6818c61126ec36e1fdcb to your computer and use it in GitHub Desktop.
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