"Из матрицы А(mxn) надо исключить строки, содержащие хотябы один нулевой элемент"
Const n = ...; m = ...; Type ma3x = array[1 .. n, 1 .. m] of integer; var mx: ma3x; i, j: integer; no_null: boolean; begin { тут заполняем матрицу } for i := 1 to n do begin no_null := true; for j := 1 to m do no_null := no_null and (arr[i, j] <> 0); if no_null then begin for j := 1 to m do write(arr[i, j]:4); writeln end; end; end.
Надо переделать для Delphi. Попробовал, получилось следующее:
var i,j,n:integer; no_null:boolean; mas:array[0..100,0..100] of integer; begin if (edit1.Text='') then showmessage('Çàïîëíèòå ïîëÿ') else begin randomize; n:=strtoint(edit1.text); stringgrid1.ColCount:=n; stringgrid1.RowCount:=n; for i:=0 to n do for j:=0 to n do begin mas[i,j]:= random(20)-10; stringgrid1.Cells[i,j] := inttostr (mas[i,j]); end; For i:=0 to n do for j:=0 to n do begin no_null:=true; no_null:=no_null and (mas[i,j]<>0); If no_null then begin for j:=0 to n do { <-- Вот в этой строке} stringgrid2.Cells[i,j] := inttostr (mas[i,j]); end;
В строке, выделеной жирнымотмеченной комментарием [Лопарь], вылезает ошибка, что цикл надо начинать с i. Как это исправить? Спасибо.
М
Lesnik, для отметки места в программе используй комментарии. Лопарь
Сообщение отредактировано: Lapp - 17.05.2007 10:00