Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program PISOS2;
- const
- max=100;
- var
- col,i,j,n:integer;
- massiv:array[1..max]of integer;
- index:array[1..2]of integer;
- begin
- repeat
- write('Введите количество элементов массива'); readln(n); //желательно вводить не менее 15 ибо рандом
- until n in[5..max];
- writeln('Массив заданный через рандом:');
- for i:=1 to n do begin
- massiv[i]:=random(21)-10;
- write(massiv[i],', ');
- end;
- writeln;
- j:=0;
- col:=0;
- for i:=1 to n do begin
- if (massiv[i]<0) then begin
- Inc(col);
- if (col in[2,5]) then begin
- Inc(j);
- index[j]:=i;
- if col=5 then break;
- end;
- end;
- end;
- if j<2 then
- writeln('В массиве меньше пяти отрицательных чисел.')
- else
- if j=2 then
- writeln('Произведение второго и пятого отрицательных чисел равно ',massiv[index[1]]*massiv[index[2]]);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement