fork download
  1. (*
  2. 課題:成績集計
  3.  
  4. 入力例
  5. 10
  6. 80
  7. 65
  8. 90
  9. 55
  10. 70
  11. 100
  12. 40
  13. 75
  14. 85
  15. 60
  16.  
  17. 出力例
  18. 平均点: 72.00
  19. 中央値: 72.50
  20. 最高点: 100
  21. 最低点: 40
  22. 標準偏差: 18.03
  23. 合格者数: 8
  24.  
  25. AI利用・修正点
  26. ・ChatGPTで作成したプログラムを基に、提出用に修正・整理した。
  27. *)
  28.  
  29. program ideone;
  30.  
  31. uses Math;
  32.  
  33. const
  34. MAX = 100;
  35.  
  36. var
  37. score, sorted: array[1..MAX] of Integer;
  38. n, i, j, temp: Integer;
  39. sum, avg, variance, sd, median, hensachi: Real;
  40. maxScore, minScore, passCount: Integer;
  41.  
  42. begin
  43. readln(n);
  44.  
  45. if n < 10 then
  46. begin
  47. writeln('10人以上入力してください。');
  48. halt;
  49. end;
  50.  
  51. sum := 0;
  52. passCount := 0;
  53.  
  54. for i := 1 to n do
  55. begin
  56. readln(score[i]);
  57. sorted[i] := score[i];
  58. sum := sum + score[i];
  59.  
  60. if score[i] >= 60 then
  61. Inc(passCount);
  62. end;
  63.  
  64. avg := sum / n;
  65.  
  66. maxScore := score[1];
  67. minScore := score[1];
  68.  
  69. for i := 2 to n do
  70. begin
  71. if score[i] > maxScore then
  72. maxScore := score[i];
  73. if score[i] < minScore then
  74. minScore := score[i];
  75. end;
  76.  
  77. variance := 0;
  78. for i := 1 to n do
  79. variance := variance + sqr(score[i] - avg);
  80.  
  81. variance := variance / n;
  82. sd := sqrt(variance);
  83.  
  84. for i := 1 to n - 1 do
  85. for j := i + 1 to n do
  86. if sorted[i] > sorted[j] then
  87. begin
  88. temp := sorted[i];
  89. sorted[i] := sorted[j];
  90. sorted[j] := temp;
  91. end;
  92.  
  93. if n mod 2 = 1 then
  94. median := sorted[(n + 1) div 2]
  95. else
  96. median := (sorted[n div 2] + sorted[n div 2 + 1]) / 2;
  97.  
  98. writeln('平均点: ', avg:0:2);
  99. writeln('中央値: ', median:0:2);
  100. writeln('最高点: ', maxScore);
  101. writeln('最低点: ', minScore);
  102. writeln('標準偏差: ', sd:0:2);
  103. writeln('合格者数: ', passCount);
  104.  
  105. writeln('偏差値');
  106. for i := 1 to n do
  107. begin
  108. if sd = 0 then
  109. hensachi := 50
  110. else
  111. hensachi := 50 + 10 * ((score[i] - avg) / sd);
  112.  
  113. writeln(i, '人目: ', hensachi:0:2);
  114. end;
  115.  
  116. end.
Success #stdin #stdout 0.01s 5276KB
stdin
10
80
65
90
55
70
100
40
75
85
60
stdout
平均点: 72.00
中央値: 72.50
最高点: 100
最低点: 40
標準偏差: 16.91
合格者数: 8
偏差値
1人目: 54.73
2人目: 45.86
3人目: 60.64
4人目: 39.95
5人目: 48.82
6人目: 66.56
7人目: 31.08
8人目: 51.77
9人目: 57.69
10人目: 42.90