👤

problemele 17 si 20 va rog

Problemele 17 Si 20 Va Rog class=
Problemele 17 Si 20 Va Rog class=

Răspuns :

Program P1;

type vector = array[1..100] of real;

var a:vector;i,n: integer;sp,si:real;

function sumapare(a:vector):real;

var i:integer;sp:real;

begin

sp:=0;

for i:=1 to n do

if  i  mod 2= 0 then sp:=sp+a[i];

sumapare:=sp;

end;

function sumaimpare(a:vector):real;

var i:integer;si:real;

begin

si:=0;

for i:=1 to n do

if   i  mod 2= 1 then si:=si+a[i];

sumaimpare:=si;

end;

begin

write('n=');readln(n);

writeln('introdu elementele tabloului:');

for i:=1 to n do readln(a[i]);

sp:=sumapare(a);si:=sumaimpare(a);

if  sp=si then writeln('Da') else writeln('nu');

readln

end.