Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(void) {
- int ints[] = {4,3,7,2,23,444,53,23,6,-1,0};
- int intsSize = sizeof(ints)/sizeof(int);
- int buffer, count, shuffleCount;
- for (count=1; count < intsSize; count++) {
- if (ints[count] < ints[0]) {
- buffer = ints[count];
- for (shuffleCount = count; shuffleCount > 0; shuffleCount--) {
- ints[shuffleCount] = ints[shuffleCount - 1];
- }
- ints[0] = buffer;
- }
- else {
- while (ints[count] < ints[count-1]) {
- buffer = ints[count-1];
- ints[count-1] = ints[count];
- ints[count] = buffer;
- count--;
- }
- }
- }
- for (count=0; count < intsSize; count++) {
- printf("%d ", ints[count]);
- }
- printf("\n");
- return 0;
- }
Add Comment
Please, Sign In to add comment