Calculates the sum of the sum and product of N numbers A,B,C

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: Homework in Pascal

Program: Suckrat.pas
File exe: Suckrat.exe
flow: Suckrat.gif

Calculates the sum of the sum and product of N numbers A,B,C. Results print as table.
{ SUCKRAT.PAS               Copyright (c) TrSek alias Zdeno Sekerak }
{ Zostavte program pre nacitanie N trojic lubovolnych cisel A,B,C   }
{ z ktorych vypocitajte sucet a sucin.                              }
{ Vysledky pre jednotlive trojice tlacte v tvare tabulky            }
{                                                                   }
{ Datum:04.02.2004                             http://www.trsek.com }
 
program sucet_sucin;
uses crt;
var a:array[1..100] of real;
    b:array[1..100] of real;
    c:array[1..100] of real;
    i:integer;
    n:integer;
    sucet:real;
    sucin:real;
 
begin
     ClrScr;
     WriteLn('Program vypocita sucet a sucin A,B,C');
     Write('Zadaj pocet trojic. Maximalne 100. N=');
     ReadLn(n);
 
     { nacita n-krat cisla a,b,c do pola }
     for i:=1 to n do
     begin
          WriteLn;
          Write('Zadaj A[',i,']='); ReadLn(a[i]);
          Write('Zadaj B[',i,']='); ReadLn(b[i]);
          Write('Zadaj C[',i,']='); ReadLn(c[i]);
     end;
 
     WriteLn('Vysledna tabulka je');
     WriteLn;
     WriteLn('Por|      A |      B |      C | Sucet       | Sucin       |');
     WriteLn('------------------------------------------------------------');
 
     { vypocita a zobrazi }
     for i:=1 to n do
     begin
          sucet := a[i] + b[i] + c[i];
          sucin := a[i] * b[i] * c[i];
          WriteLn( i:3,'|', a[i]:8:3, '|', b[i]:8:3, '|', c[i]:8:3, '|', sucet:13:3, '|', sucin:13:3, '|' );
     end;
 
     WriteLn('------------------------------------------------------------');
     ReadLn;
end.