fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int scores[10];
  5. int data[10];
  6.  
  7. for (int i = 0; i < 10; i++) {
  8. scanf("%d", &scores[i]);
  9. data[i] = i + 1;
  10. }
  11.  
  12. for (int i = 0; i < 9; i++) {
  13. for (int j = i + 1; j < 10; j++) {
  14. if (scores[i] < scores[j]) {
  15. int temp = scores[i];
  16. scores[i] = scores[j];
  17. scores[j] = temp;
  18. int tempIndex = data[i];
  19. data[i] = data[j];
  20. data[j] = tempIndex;
  21. }}}
  22. printf("合格者:\n");
  23. for (int i = 0; i < 3; i++) {
  24. printf("%d人目 %d点\n", data[i],scores[i]);
  25. }
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 5276KB
stdin
84 86 81 72 95 48 93 74 98 61
stdout
合格者:
9人目 98点
5人目 95点
7人目 93点