Basic Pascal Tutorial/Chapter 1/Solution/ja

From Lazarus wiki
Jump to navigationJump to search

български (bg) Deutsch (de) English (en) français (fr) 日本語 (ja) 한국어 (ko) русский (ru) 中文(中国大陆) (zh_CN)

1Ha - 解答例 (著者: Tao Yue, 状態: 原文のまま修正なし)

前のセクションのプログラミング練習問題を解いた一つの例をここに示す。

(* Author:    Tao Yue
   Date:      19 June 1997
   記述:
      5つの事前に定まっている値の合計と平均を求める
   Version:
      1.0 - original version
*)

program SumAverage;

const
   NumberOfIntegers = 5;

var
   A, B, C, D, E : integer;
   Sum : integer;
   Average : real;

begin    (* Main *)
   A := 45;
   B := 7;
   C := 68;
   D := 2;
   E := 34;
   Sum := A + B + C + D + E;
   Average := Sum / NumberOfIntegers;
   writeln ('Number of integers = ', NumberOfIntegers);
   writeln ('Number1 = ', A);
   writeln ('Number2 = ', B);
   writeln ('Number3 = ', C);
   writeln ('Number4 = ', D);
   writeln ('Number5 = ', E);
   writeln ('Sum = ', Sum);
   writeln ('Average = ', Average)
end.     (* Main *)
previous contents next