fork download
  1. #include <stdio.h>
  2. #define NUM 5
  3.  
  4. int main(void)
  5. {
  6. int test[NUM];
  7. int tmp;
  8. int i, j, s ,t;
  9.  
  10. printf("%d人の点数を入力してください。\n",NUM);
  11. for(i=0; i<NUM; i++){
  12. scanf("%d",&test[i]);
  13. }
  14. for(s=0; s<NUM-1; s++){
  15. for(t=s+1; t<NUM; t++){
  16. if(test[t] > test[s]){
  17. tmp = test[t];
  18. test[t] = test[s];
  19. test[s] = tmp;
  20. }
  21. }
  22. }
  23.  
  24. for(j=0; j<NUM; j++){
  25. printf("%d番目の人の点数は%dです。\n", j+1, test[j]);
  26. }
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5320KB
stdin
22
80
45
60
3
stdout
5人の点数を入力してください。
1番目の人の点数は80です。
2番目の人の点数は60です。
3番目の人の点数は45です。
4番目の人の点数は22です。
5番目の人の点数は3です。