fork download
  1. //(h)ttps://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12261938812
  2.  
  3. #include <stdio.h>
  4. int main(void){
  5. int x[10]={-3,28,0,8,-17,3,95,-77,34,51},i,j,m,n;
  6. for(i = 0; i < 10; i++){
  7. n = x[i];
  8. m = i;
  9. for(j = i; j < 10; j++){
  10. if(n < x[j]){
  11. n = x[j];
  12. m = j;
  13. }
  14. }
  15. x[m] = x[i];
  16. x[i] = n;
  17. }
  18. for(i = 0; i <= 9; i++) printf("%d ", x[i]);
  19. printf("\n");
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5540KB
stdin
Standard input is empty
stdout
95 51 34 28 8 3 0 -3 -17 -77