fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int score[10];
  6. int rank[5] = {0};
  7. int num, r, i;
  8.  
  9. printf("人数=\n");
  10. scanf("%d", &num);
  11. for (i = 0; i < num; i++) {
  12. printf("%d: 点数=\n", i + 1);
  13. scanf("%d", &score[i]);
  14. }
  15.  
  16. for (i = 0; i < num; i++) {
  17. r = score[i] / 20;
  18. if (4 < r) r = 4;
  19. rank[r]++;
  20. }
  21. for (i = 0; i < 5; i++) {
  22. printf("%d点以上=%d\n", i * 20, rank[i]);
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 1680KB
stdin
10
53
45
98
100
0
3
43
67
32
19
stdout
人数=
1: 点数=
2: 点数=
3: 点数=
4: 点数=
5: 点数=
6: 点数=
7: 点数=
8: 点数=
9: 点数=
10: 点数=
0点以上=3
20点以上=1
40点以上=3
60点以上=1
80点以上=2