Acasa Tehnologie Calcul media aritmetica a elementelor unui vector

Calcul media aritmetica a elementelor unui vector

by Dragos Schiopu

programare

>Calculeaza media aritmetica a elementelor dintr-un vector.

program media_arit;
var v:array[1..50]of integer;
    n,ma,i,nr,s:integer;
begin
     write('n=');readln(n);
     for i:=1 to n do begin
         write('v[',i,']=');readln(v[i]);
         end;
     for i:=1 to n do write(v[i], ' ');
     s:=0; nr:=0;
     for i:=1 to n do begin
         s:=s+v[i];
         inc(nr);
         end;
     if nr>0 then writeln('media arit=', s/nr);
     readln;
end.
{ by Maria  PascalZone.evonet.ro}

s-ar putea sa-ti placa