fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int score[10];
  6. int i, j;
  7. int max;
  8. int index;
  9.  
  10. for(i = 0; i < 10; i++)
  11. {
  12. printf("%d人目の点数:", i + 1);
  13. scanf("%d", &score[i]);
  14. }
  15.  
  16. printf("\n合格者:");
  17.  
  18. for(j = 0; j < 3; j++)
  19. {
  20. max = -1;
  21.  
  22. for(i = 0; i < 10; i++)
  23. {
  24. if(score[i] > max)
  25. {
  26. max = score[i];
  27. index = i;
  28. }
  29. }
  30.  
  31. printf("%d人目 ", index + 1);
  32. score[index] = 0;
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1人目の点数:2人目の点数:3人目の点数:4人目の点数:5人目の点数:6人目の点数:7人目の点数:8人目の点数:9人目の点数:10人目の点数:
合格者:9人目 3人目 8人目