fork(1) download
  1. program ideone;
  2. begin
  3. (* yoprogram GradeAnalysis;
  4. {$MODE OBJFPC}
  5.  
  6. uses
  7.   math, sysutils;
  8.  
  9. var
  10.   // 元の点数データ
  11.   originalScores: array[0..9] of Double = (60, 70, 80, 90, 50, 40, 100, 85, 75, 65);
  12.   // ソート計算用配列
  13.   sortedScores: array[0..9] of Double;
  14.   i, j, passCount: Integer;
  15.   sum, mean, median, maxScore, minScore, stdDev, temp: Double;
  16.  
  17. begin
  18.   // 1. 各種計算の準備
  19.   sum := 0;
  20.   passCount := 0;
  21.   for i := 0 to 9 do
  22.   begin
  23.   sortedScores[i] := originalScores[i];
  24.   sum := sum + originalScores[i];
  25.   if originalScores[i] >= 60 then Inc(passCount);
  26.   end;
  27.  
  28.   mean := sum / 10;
  29.  
  30.   // 標準偏差の計算 (手動計算)
  31.   sum := 0;
  32.   for i := 0 to 9 do
  33.   sum := sum + sqr(originalScores[i] - mean);
  34.   stdDev := sqrt(sum / 10);
  35.  
  36.   // 2. 中央値などを出すためのソート
  37.   for i := 0 to 8 do
  38.   for j := i + 1 to 9 do
  39.   if sortedScores[i] > sortedScores[j] then
  40.   begin
  41.   temp := sortedScores[i];
  42.   sortedScores[i] := sortedScores[j];
  43.   sortedScores[j] := temp;
  44.   end;
  45.  
  46.   minScore := sortedScores[0];
  47.   maxScore := sortedScores[9];
  48.   median := (sortedScores[4] + sortedScores[5]) / 2;
  49.  
  50.   // 3. 結果の出力(すべて英語にしました)
  51.   WriteLn('Average: ', mean:0:2);
  52.   WriteLn('Median: ', median:0:2);
  53.   WriteLn('Max Score: ', maxScore:0:2);
  54.   WriteLn('Min Score: ', minScore:0:2);
  55.   WriteLn('Std Deviation: ', stdDev:0:2);
  56.   WriteLn('Passed Count: ', passCount);
  57.   WriteLn('--- Deviation Scores per Student ---');
  58.  
  59.   for i := 0 to 9 do
  60.   begin
  61.   WriteLn('Student ', i+1, ': ', (50 + 10 * (originalScores[i] - mean) / stdDev):0:2);
  62.   end;
  63.  
  64.   // 画面を一時停止する
  65.   ReadLn;
  66. end.ur code goes here *)
  67. end.
Success #stdin #stdout 0s 5320KB
stdin
60, 70, 80, 90, 50, 40, 100, 85, 75, 65
stdout
Standard output is empty