Last active
May 23, 2016 23:28
-
-
Save Marzogh/df252fb74bd16a1dc269c7ce80ad9d87 to your computer and use it in GitHub Desktop.
Sorts an array of integers using a bubble sort algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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