В одномерном массиве, состоящем из n вещественных элементов, вычислить: произведение отрицательных элементов массива — Pascal(Паскаль)

program hhh;
Uses crt;
 Var x:array [1..100] of real;
     i,j,n:integer;
     max,s,p:real;
begin
clrscr;
Writeln (' Vvedite kol - vo elementov ');
Readln (n);
 for i:=1 to n do begin
                  write ('Vvedite ',i, ' element ');
                  Readln (x[i]);
                  end;
Writeln (' polycheny chisla ');
for i:=1 to n do write (x[i]:3);
writeln;
p:=1;
for i:=1 to n do
 if x[i]<0 then p:=p*x[i];
writeln (' Proizvedenie otricatelnyx elementov = ',p);
Max:=x[1];
for i:=1 to n do
  if x[i]>=max then begin
                    max:=x[i];
                    j:=i;
                    end;
Writeln (' Maxim element = ',max);
s:=0;
for i:=1 to j-1 do
  if x[i]>=0 then s:=s+x[i];
writeln (' Summa polozhitelnyx elementov =',s);
Readln
end.

Leave a Comment

+ 71 = 77