Acasa Tehnologie Citire si afisare vector

Citire si afisare vector

by Dragos Schiopu

programare

>Citeste un vector, il afiseaza, calculeaza cate elem sunt mai mari, mai mici sau egale cu 0.

program vect;
uses crt;
var a:array[1..20] of integer;
i,n,k,t,q:integer;

function max(b,c:integer):integer;
begin
if b>c then max:=b;
if b<c then max:=c;
end;

BEGIN
clrscr;
read(n);
for i:=1 to n do
begin
write('Dati a[',i,']=');
readln(a[i]);
end;
writeln('Vectorul este:');
for i:=1 to n do write(a[i]:2);
for i:=1 to n do if max(a[i],0)=a[i] then k:=k+1;
for i:=1 to n do if max(a[i],0)=0 then t:=t+1;
q:=n-t-k;
writeln('Nr de elem >0 sunt ',k);
writeln('Nr de elem <0 sunt ',t);
writeln('Nr de elem =0 sunt ',q);
readkey;
end.
{PascalZone.uv.ro}

s-ar putea sa-ti placa