👤
a fost răspuns

Se da un vector cu (1<=n<=100) componente numere intregi sa se afle compozitia maxima negativa

Răspuns :

program ComponentaMaxNeg;

const nmax=100;

type Vector = array[1..nmax] of integer;

var  V: Vector;

    negMax, n, i: integer;

begin

  write('n='); read(n);

  writeln(' introdu ',n,' componente intregi:');

  for i:=1 to n do

     begin

         read (V[i]);

     end;

  i:=1;

  while (V[i]>=0) do  i:=i+1;

  if i=n+1 then writeln(' nu exista negative...')

  else

     begin

          negMax:=V[i];

          for i:=i to n do

              if (V[i]<0) and (V[i]>negMax) then negMax:=V[i];

          writeln(' componenta negativa maxima este ', negMax);

     end;

end.