English
English
Slovensky
Slovensky
Česky
Česky
Šarišsky
Šarišsky
 
Category: Homework in Pascal

Program: Suma.pas
File exe: Suma.exe
Calculates the sum of the multipication results a[i]*b[n+1-i], where n stands for the number of arithmetical values.
Views: 820x


{ SUMA.PAS                  Copyright (c) TrSek alias Zdeno Sekerak }
{ Vypocita sumu sucinov a[i]*b[n+1-i], pricom n je pocet cisel      }
{ Vstup : pole a, b cisel                                           }
{ Vystup: suma sucinov                                              }
{                                                                   }
{ Datum:10.04.2000                             http://www.trsek.com }
 
program suma (input, output);
var s,i,n : integer;
    a, b  : array [1..20] of integer;
begin
   s := 0;
   write ('zadaj n: ');
   readln (n);
   for i:=1 to n do begin
      write ('zadaj a[',i,']: ');
      readln (a[i]);
      write ('zadaj b[',i,']: ');
      readln (b[i]);
   end;
   for i:=1 to n do s:=s+(a[i]*b[n+1-i]);
   writeln ('suma je ', s);
   readln;
end.
 
 

[Run] [Save] [Print] [Send e-mail]