ger): integer;:=StrToInt (StringGrid1.Cells [x, y]) ;;, index2, s, old_s: integer ;, plan, potential: TData; .Lines.Clear;
//Прочитати дані з гріда:=TData.Create; .Width:=StringGrid1.ColCount - 2; .Height:=StringGrid1.RowCount - 2; index:=0 to data.Height - 1 doindex2:=0 to data.Width - 1 do.Arr [index2, index]:=GetInt (index2 + 2, index + 2); index:=0 to data.Width - 1 do.Top [index]:=GetInt (index + 2, 1); index:=0 to data.Height - 1 do.Left [index]:=GetInt (1, index + 2);:=TData.Create;:=TData.Create;
Memo1.Lines.Add ( Вихідні дані );
Dump (data, 7) ;. Lines.Add ( Вихідний план: ); (data, plan); (plan, 1) ;. Lines.Add ( S min: + IntToStr (CalcSum (data, plan))); {} _s:=0; (true) do (data, plan, potential) ;. Lines.Add ( Потенціал: ); (potential, 1); {} (potential.Min gt;=0) then
begin.Lines.Add ( Успішно завершено );
break ;;
(data, plan, potential);:=CalcSum (data, plan) ;. Lines.Add ( План: ); (plan, 1) ;. Lines.Add ( laquo ; S min: + IntToStr (s)); {} [ii]:=CalcSum (data, plan); (old_s=s) then_s:=s ;;;
{TData} TData.Assign (data: TData) ;, index2: integer; (data); index:=0 to Height - 1 doindex2:=0 to Width - 1 do [index2, index ]:=data.Arr [index2, index] ;; TData.AssignLT (data: TData) ;: integer ;;:=data.Width;:=data.Height; index:=0 to Width - 1 do [index] :=data.Top [index]; index:=0 to Height - 1 do [index]:=data.Left [index] ;; TData.Create ;;; TForm1.Check (data: TData): boolean ;, index:integer;:=0; index:=0 to data.Width - 1 do:=s + data.Top [index]; index:=0 to data.Height - 1 do:=s - data.Left [index] ;
Result:=s=0;// Чи тут більше поставити?
end; TForm1.CalcNorthWest (data: TData; var plan: TData) ;, index2, t: integer;:=0;:=0; .AssignLT (data); (index lt; plan.Height) and (index2 lt; plan.Width) do:=min (plan.Left [index], plan.Top [index2]) ;. Arr [index2, index]:=t; .Top [index2]:= plan.Top [index2] -t;
plan.Left [index]:=plan.Left [index] -t; (plan.Top [index2]=0) then:=index2 + 1; (plan.Left [index]= 0) then:=index + 1 ;;
TForm1.Dump (data: TData; fl: integer); i2s (i: integer): string ;: string;:=IntToStr (i); (length (r) lt; 3) do := + R;:=r ;;
, index2: integer ;: string;
//top ((fl and 2) lt; gt; 0) then:= raquo ;; index:=0 to data.Width - 1 do:=s + i2s (data.Top [index]) ;. Lines.Add (s) ;; ((fl and 5)=0) then; index: =0 to data.Height - 1 do
//left ((fl and 4) lt; gt; 0) then:=i2s (data.Left [index]):= raquo ;;
//arr ((fl and 1) lt; gt; 0) thenindex2:=0 to data.Width - 1 do:=s + i2s (data.Arr [index2, index]);.Lines.Add (s) ;;
TForm1.Button3Click (Sender: TObject); c (x, y: integer; s: string) ;. Cells [x, y]:=s ;;:=1; .Picture.LoadFromFile ( 1.jpg ) ;. ColCount:=7; .RowCount:=4;
//top (2, 1, 7 ); (3, 1, 8 ); (4, 1, 10 ); (5, 1, laquo ; 9 ); (6, 1, 11 );
//left (1, 2, 20 ); (1, 3, 25 );
//mid (2, 2, 2 ); (3, 2, 4 ); (4, 2, 5 ); (5, 2, laquo ; 6 ); (6, 2, 8 ); (2, 3, 3 ); (3, 3, 5 ); (4, 3, 7 ); ( 5, 3, 9 ); (6, 3, 5 ) ;;
TForm1.CalcSum (data, plan: TData): integer ;, index2, s: integer;:=0; index:=0 to data.Height - 1 doindex2:=0 to data.Width- 1 do:=s + data.Arr [index2, index] * plan.Arr [index2, index];:=s ;;
TForm1.Button4Click (Sender: TObject); c (x, y: integer; s: string) ;. Cells [x, y]:=s ;;:=2; .Picture.LoadFromFile ( 2.jpg ) ;. ColCount:=7; .RowCount:=4;
//top (2, 1, 7 ); (3, 1, 8 ); (4, 1, 10 ); (5, 1, laquo ; 9 ); (6, 1, 11 );
//left (1, 2, 20 ); (1, 3, 25 );
//mid (2, 2, 10 ); (3, 2, 8 ); (4, 2, 6 ); (5, 2, laquo ; 5 ); (6, 2, 2 ); (2, 3, 9 ); (3, 3, 7 ); (4, 3, 5 ); ( 5, 3, 4 ); (6, 3, 3 ) ;;
TData.Min: integer ;, index2, m: integer;:=MaxInt; index:=0 to Height - 1 doindex2:=0 to Width - 1 do (m gt; Arr [index2, index]) then:=Arr [index2, index];:=m ;; TData.NoNulls: integer;
index, index2, c: integer;:=0; index:=0 to Height - 1 doindex2:=0 to Width - 1 do (Arr [index2, index] gt; 0) then ( c);:=c ;; TForm1.CalcMinEl (data: TData; var plan: TData) ;, index2, x_m, y_m, v_m, s, v: integer;:=0; .AssignLT (data); index:= 0 to plan.Width - 1 do:=s + data.Top [index]; (s gt; 0) do_m:=MaxInt; _m:=- 1; _m:=- 1; index:=0 to plan.Height- 1 doindex2:=0 to plan.Width - 1 do ((v_m gt; data.Arr [index2, index]) and
(plan.Arr [index2, index]=0) and
(plan.Top [index2] gt; 0) and (plan.Left [index]...