Дана последовательность целых чисел а1, а2,…, аn. Выяснить, какое число встречается раньше — положительное или отрицательное — Pascal(Паскаль)



const
n=10;
var
i,p:integer;
a:array[1..n] of integer;
begin
for i:=1 to n do
  begin
      a[i]:=10-random(20);
      write(' ',a[i]:3);
  end;
writeln();
writeln('-------');

p:=0;  i:=0;
repeat i:=i+1;
if a[i]<>0 then begin
  p:=1;
  if a[i]>0 then write('Polozhitelnoe');
  if a[i]<0 then write('Otritcatelnoe');
end;
until (p=1) or (i=n);

writeln('-------');

end.

Leave a Comment

39 − 37 =