Skip to content

Instantly share code, notes, and snippets.

@Marzogh
Last active May 23, 2016 23:28
Show Gist options
  • Save Marzogh/df252fb74bd16a1dc269c7ce80ad9d87 to your computer and use it in GitHub Desktop.
Save Marzogh/df252fb74bd16a1dc269c7ce80ad9d87 to your computer and use it in GitHub Desktop.
Sorts an array of integers using a bubble sort algorithm
void sort(int a[], int size) {
for(int i=0; i<(size-1); i++) {
for(int o=0; o<(size-(i+1)); o++) {
if(a[o] > a[o+1]) {
int t = a[o];
a[o] = a[o+1];
a[o+1] = t;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment