fork download
  1. #include <stdio.h>
  2. #define NUM 10
  3. int main() {
  4. int scores[NUM] = {25, 39, 42, 76, 35, 48, 81, 41, 74, 55};
  5. printf("\n合格者:");
  6. for (int k = 0; k < 3; k++) {
  7. int max_score = -1;
  8. int max_index = -1;
  9. for (int i = 0; i < NUM; i++) {
  10. if (scores[i] > max_score) {
  11. max_score = scores[i];
  12. max_index = i;
  13. }
  14. }
  15. printf("%d人目", max_index + 1);
  16. if (k < 2) printf(" ");
  17. scores[max_index] = -1;
  18. }
  19.  
  20. printf("\n");
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
合格者:7人目 4人目 9人目