Skip to content

Instantly share code, notes, and snippets.

@huseyin
Last active April 9, 2019 18:43
Show Gist options
  • Save huseyin/1ec57fa1e8a39ac5512088b2a1255264 to your computer and use it in GitHub Desktop.
Save huseyin/1ec57fa1e8a39ac5512088b2a1255264 to your computer and use it in GitHub Desktop.
#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