Advertisement
Guest User

Untitled

a guest
May 31st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.01 KB | None | 0 0
  1. program PISOS2;
  2. const
  3.   max=100;
  4. var
  5.   col,i,j,n:integer;
  6.   massiv:array[1..max]of integer;
  7.   index:array[1..2]of integer;
  8. begin
  9.   repeat
  10.     write('Введите количество элементов массива'); readln(n); //желательно вводить не менее 15 ибо рандом
  11.   until n in[5..max];
  12.   writeln('Массив заданный через рандом:');
  13.   for i:=1 to n do begin
  14.     massiv[i]:=random(21)-10;
  15.     write(massiv[i],', ');
  16.   end;
  17.   writeln;
  18.   j:=0;
  19.   col:=0;
  20.   for i:=1 to n do begin
  21.     if (massiv[i]<0) then begin
  22.       Inc(col);
  23.       if (col in[2,5]) then begin
  24.         Inc(j);
  25.         index[j]:=i;
  26.         if col=5 then break;
  27.       end;
  28.     end;
  29.   end;
  30.   if j<2 then
  31.   writeln('В массиве меньше пяти отрицательных чисел.')
  32.   else
  33.   if j=2 then
  34.   writeln('Произведение второго и пятого отрицательных чисел равно ',massiv[index[1]]*massiv[index[2]]);
  35. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement