Last active
April 9, 2019 18:43
-
-
Save huseyin/1ec57fa1e8a39ac5512088b2a1255264 to your computer and use it in GitHub Desktop.
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#define LENGTH 10 | |
int main(void) { | |
int unordered[LENGTH] = {8, 2, 4, 9, 3, 7, 1, 0, 5, 6}; | |
int swap, i, j; | |
for (i=0; i < LENGTH; i++) { | |
for (j=0; j < LENGTH - i; j++) { | |
if (j+1 == LENGTH) | |
break; | |
if (unordered[j] > unordered[j+1]) { | |
swap = unordered[j+1]; | |
unordered[j+1] = unordered[j]; | |
unordered[j] = temp; | |
} | |
} | |
} | |
for (i=0; i < LENGTH; i++) { | |
printf("%d\n", unordered[i]); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment