fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int scores[10];
  5. int lucky_index = -1;
  6. int ninth_score;
  7.  
  8. for (int i = 0; i < 10; i++) {
  9. scanf("%d", &scores[i]);
  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. }
  19. }
  20. }
  21.  
  22. ninth_score = scores[8];
  23.  
  24. int count = 0;
  25. for (int i = 0; i < 10; i++) {
  26. if (scores[i] == ninth_score) {
  27. count++;
  28. if (lucky_index == -1) {
  29. lucky_index = i + 1;
  30. }
  31. }
  32. }
  33. printf("9位の点数:%d\n", ninth_score);
  34. printf("ラッキーな人:%d人目\n", lucky_index);
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 5308KB
stdin
20 50 40 37 68 18 28 38 58 97
stdout
9位の点数:20
ラッキーな人:9人目