Acasa Tehnologie Produsul a 2 vectori recursiv

Produsul a 2 vectori recursiv

by Dragos Schiopu

>

program mm135_8;
type vector=array[1..100] of integer;
var v,u,p:vector;
i,n:integer;

function produs(a:integer):integer;
var prod:integer;
begin
if a>n then prod:=0
else prod:=produs(a+1)+v[a]*u[a];
produs:=prod;
end;

begin
write('n=');
readln(n);
writeln('Citire si afisare vector U:');
for i:=1 to n do
begin
write('u[',i,']=');
readln(u[i]);
end;
for i:=1 to n do
write(u[i],' ');
writeln;

writeln('Citire si afisare vector V:');
for i:=1 to n do
begin
write('v[',i,']=');
readln(v[i]);
end;
for i:=1 to n do
write(v[i],' ');
writeln;
write(produs(1));
readln;
end.
{PascalZone.uv.ro}

s-ar putea sa-ti placa