fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int length = 15;
  7. int array[] = { 11, 42, 33, 14, 55, 36, 123, 241, 73, 82, 218, 46, 153, 108, 52 };
  8. for (int startIndex = 0; startIndex < length - 1; ++startIndex)
  9. {
  10. int maxIndex = startIndex;
  11.  
  12. for (int currentIndex = startIndex + 1; currentIndex < length; ++currentIndex)
  13. {
  14. if (array[currentIndex] > array[maxIndex])
  15.  
  16. maxIndex = currentIndex;
  17. }
  18.  
  19. int t = array[startIndex];
  20. array[startIndex]= array[maxIndex];
  21. array[maxIndex] = t;
  22. }
  23.  
  24. for (int index = 0; index < length; ++index)
  25. printf("%i ", array[index]);
  26.  
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5512KB
stdin
Standard input is empty
stdout
241  218  153  123  108  82  73  55  52  46  42  36  33  14  11