fork download
  1. #include <stdio.h>
  2.  
  3. struct student {
  4. int bangou;
  5. int tokuten;
  6. int hyouka;
  7. };
  8.  
  9. int main()
  10. {
  11. struct student s[10];
  12. int i, bangou, tokuten, goukei = 0, heikin, sa, hyouka;
  13.  
  14. for (i = 0; i < 10; i++) {
  15. scanf("%d %d", &bangou, &tokuten);
  16. s[i].bangou = bangou;
  17. s[i].tokuten = tokuten;
  18. goukei += tokuten;
  19. }
  20. heikin = goukei / 10;
  21. for (i = 0; i < 10; i++) {
  22. sa = s[i].tokuten - heikin;
  23.  
  24. if (20 <= sa) hyouka = 0;
  25. else if (10 <= sa) hyouka = 1;
  26. else if (0 <= sa) hyouka = 2;
  27. else if (-20 <= sa) hyouka = 3;
  28. else hyouka = 4;
  29.  
  30. s[i].hyouka = hyouka;
  31. }
  32. for (hyouka = 0; hyouka < 5; hyouka++) {
  33. printf("\n評価:%c\n", "SABCF"[hyouka]);
  34. for (i = 0; i < 10; i++) {
  35. if (s[i].hyouka == hyouka) {
  36. printf("%d %d\n", s[i].bangou, s[i].tokuten);
  37. }
  38. }
  39. }
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0.01s 1724KB
stdin
1 100
2 80
3 77
4 34
5 98
6 0
7 46
8 87
9 36
10 55
stdout
評価:S
1 100
5 98
8 87

評価:A
2 80
3 77

評価:B

評価:C
7 46
10 55

評価:F
4 34
6 0
9 36