Skip to content

Instantly share code, notes, and snippets.

@jeonghwan-kim
Created October 25, 2013 01:28
Show Gist options
  • Select an option

  • Save jeonghwan-kim/7148104 to your computer and use it in GitHub Desktop.

Select an option

Save jeonghwan-kim/7148104 to your computer and use it in GitHub Desktop.
Bubble sort
void bubble_sort(int a[], int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1 - i; j++) {
if (a[j] > a[j + 1]) {
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment