0% found this document useful (0 votes)
37 views2 pages

(Vectorul e Un Tabel Unidimensional) (Citire Vector Iterativ)

The document defines several functions that perform iterative operations on vectors and integers. It declares a vector type and variables, then defines functions to read from and write to a vector, sum the elements of a vector, take the product of elements, calculate the factorial of an integer, and find the average of a vector's elements. These functions each use a for loop to iterate over the vector or integer range to perform the desired operation.

Uploaded by

Cristina Apostol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

(Vectorul e Un Tabel Unidimensional) (Citire Vector Iterativ)

The document defines several functions that perform iterative operations on vectors and integers. It declares a vector type and variables, then defines functions to read from and write to a vector, sum the elements of a vector, take the product of elements, calculate the factorial of an integer, and find the average of a vector's elements. These functions each use a for loop to iterate over the vector or integer range to perform the desired operation.

Uploaded by

Cristina Apostol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

type vec= array[1..

100] of integer;

var mx,a: vec;


n,m: integer;

{Vectorul e un tabel unidimensional}

{Citire vector iterativ}


function cvec(n:integer):integer;
var i:integer;
begin
for i:=1 to n do
readln(a[i]);
cvec:=0;
end;

{Afisare vector iterativ}


function avec(n:integer):integer;
var i:integer;
begin
for i:=1 to n do
writeln(a[i]);
avec:=0;
end;

{Suma vector iterativ}


function svec(n:integer):integer;
var k,i:integer;
begin
for i:= 1 to n do
k:=k+a[i];
svec:=k;
end;

{Produs vector iterativ}


function pvec(n:integer):integer;
var i,k:integer;
begin
k:=1;
for i:= 1 to n do
k:=k*a[i];
pvec:=k;
end;

{Factorial iterativ}
function fac(n:integer):integer;
var i,k:integer;
begin
k:=1;
for i:= 1 to n do
k:=k*i;
fac:=k;
end;

{Medie vector iterativ}


function mvec(n:integer):real;
var i,j,k,s:integer;
begin
for i:= 1 to n do
s:=s+a[i];
mvec:=s/k;
end;

begin
readln(n);
readln(m);
Writeln(fac(n));
Writeln(fac(m));
end.

You might also like