Make the program whos finished when entered N
Delphi & Pascal (česká wiki)
Category: Homework in Pascal
Program: Priem2.pas
File exe: Priem2.exe
flow: Priem2.gif
Program: Priem2.pas
File exe: Priem2.exe
flow: Priem2.gif
Make the program whos finished when entered N. Print some of number division of mean of number xx/xpr. Print this number as table.
{ PRIEM2.PAS Copyright (c) TrSek alias Zdeno Sekerak } { Zostavte program, ak posledne cislo na vstupe je N. } { Vytlacte kazdu z tychto hodnot vydelenu ich priemerom v tvare } { tabulky xx/xpr. Vytlacte sucet povodnych i vydelenych hodnot } { } { Datum:04.02.2004 http://www.trsek.com } program priemer; uses crt; var c:array[1..100] of real; n:real; suc:real; priem:real; vstup:real; sum1:real; sum2:real; poc:integer; i:integer; begin ClrScr; WriteLn('Program vytlaci tabulku nacitanych cisel vydelenych ich priemerom'); Write('Zadaj ukoncovacie cislo n:'); ReadLn(n); { pociatocne hodnoty } poc := 0; suc := 0; { nacita az pokial nezada c=k } repeat Write('Zadaj c[',poc+1,']='); ReadLn(vstup); { spocitavam suc } if( vstup <> n )then begin poc := poc + 1; c[poc] := vstup; suc := suc + vstup; end; until (vstup = n); { ak zadal neaky vstup } if( poc > 0 )then begin priem := suc / poc; sum1 := 0; sum2 := 0; WriteLn('Vysledna tabulka je'); WriteLn; WriteLn('|Por| X | X/Priem|'); WriteLn('-----------------------'); for i:=1 to poc do begin sum1 := sum1 + c[i]; sum2 := sum2 + c[i]/priem; WriteLn('|', i:3, '|', c[i]:8:3, '|', (c[i]/priem):8:3, '|'); end; WriteLn('-----------------------'); WriteLn(' |', sum1:8:3, '|', sum2:8:3, '|'); WriteLn('-----------------------'); end; ReadLn; end.