var a: array[1..n, 1..m] of integer; i, j: integer;
function check(i: integer): boolean; var j: integer; begin check := false; j := 0; repeat inc(j); if a[i, j] < 0 then begin check := true; exit; end; until j = m; end;
function search: integer; var i: integer; begin search := 0; i := 0; repeat inc(i); if not(check(i)) then begin search := i; exit; end; until i = n; end;
begin writeln('Введите матрицу ', n, 'x', m,': '); i := 0; repeat j := 0; inc(i); repeat inc(j); read(a[i, j]); until j = m; until i = n; writeln('ответ: ', search); end. Пример работы программы: Введите матрицу 5x5: 3 4 2 3 -2 3 -5 -7 -2 1 8 2 5 4 -4 0 1 2 3 4 1 7 2 -5 2 ответ: 4 * Примечание: Если во всех строках есть отрицательные элементы, то ответ будет 0 (можно изменить в самой процедуре)