Skip to content

Instantly share code, notes, and snippets.

@ruanchao
Created July 7, 2012 04:15
Show Gist options
  • Save ruanchao/3064578 to your computer and use it in GitHub Desktop.
Save ruanchao/3064578 to your computer and use it in GitHub Desktop.
Bubble sort - C
#include <stdio.h>
void bubbleSort(int arr[], int count)
{
int i = count, j;
int temp;
while(i > 0)
{
for(j = 0; j < i - 1; j++)
{
if(arr[j] > arr[j + 1])
{ temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
i--;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment