Guest User

Untitled

a guest
May 26th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void) {
  5. int ints[] = {4,3,7,2,23,444,53,23,6,-1,0};
  6. int intsSize = sizeof(ints)/sizeof(int);
  7. int buffer, count, shuffleCount;
  8.  
  9. for (count=1; count < intsSize; count++) {
  10. if (ints[count] < ints[0]) {
  11. buffer = ints[count];
  12. for (shuffleCount = count; shuffleCount > 0; shuffleCount--) {
  13. ints[shuffleCount] = ints[shuffleCount - 1];
  14. }
  15. ints[0] = buffer;
  16. }
  17. else {
  18. while (ints[count] < ints[count-1]) {
  19. buffer = ints[count-1];
  20. ints[count-1] = ints[count];
  21. ints[count] = buffer;
  22. count--;
  23. }
  24. }
  25. }
  26.  
  27. for (count=0; count < intsSize; count++) {
  28. printf("%d ", ints[count]);
  29. }
  30. printf("\n");
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment