gt; 0)) then_m:=data.Arr [index2, index]; _ m:=index2; _m :=index ;; (v_m=MaxInt) then;:=min (plan.Top [x_m], plan.Left [y_m]) ;. Top [x_m]:=plan.Top [x_m] - v; .Left [ y_m]:=plan.Left [y_m] - v; .Arr [x_m, y_m]:=v;:=s - v ;; TData.Reset; (Left, sizeof (Left), 0); (Top, sizeof (Top), 0); (Arr, sizeof (Arr), 0) ;;
{TEqSolve} TEqSolve.AddEq (p1, p2, s: integer); [fEqCount] .p1:=p1; [fEqCount] .p2:=p2 + fH; [fEqCount] .sum: =s; [fEqCount] .solved:=false;
//Дебужний висновок уравненій.Memo1.Lines.Add ( u + IntToStr (p1 + 1) + + v + IntToStr (p2 + 1) +
= Raquo; + IntToStr (s)); {} (FEqCount) ;; TEqSolve.Create (h, v_c: integer); (Eq, sizeof (Eq), 0); (fV, sizeof (fV), 0);:=0;:=v_c;:= h ;;
TEqSolve.GetU (index: integer): TVar;:=fV [index] ;; TEqSolve.GetV (index: integer): TVar;:=fV [index + fH] ;; TEqSolve. Solve; _solved, index, c: integer ;: ^ TEquation; (fV, sizeof (fV), 0); _ solved:=fVarCount - 1; [0] .v:=0; [0] .solved:=true; (non_solved gt; 0) do:=0; index:=0 to fEqCount - 1 do: =Eq [index]; (ceq.solved) then continue; (fV [ceq.p1] .solved) then [ceq. p2] .v:=ceq.sum - fV [ceq.p1] .v; [ceq.p2] .solved:=true; (c) ;. solved:=true; if (fV [ceq.p2] .solved ) then [ceq.p1] .v:=ceq.sum - fV [ceq.p2] .v; [ceq.p1] .solved:=true; (c) ;. solved:=true ;;;// For (c=0) then ;; TForm1.CalcPotential (data: TData; var plan, x: TData); to_sign (v: integer): integer; (v=0) then:=1:=- 1; ;, index2, t: integer;
solve: TEqSolve ;: string;
//Створити систему рівнянь і вирішити її
solve:=TEqSolve.Create (plan.Height, plan.Height + plan.Width); index:=0 to plan.Height - 1 doindex2:=0 to plan.Width - 1 do ( plan.Arr [index2, index] gt; 0) then.AddEq (index, index2, data.Arr [index2, index]);
//Бракує рівнянь - добудувати їх:=0;
index2:=0; (solve.fEqCount lt; plan.Height + plan.Width - 1) do (index2); (index2=plan.Width) then:=0; (index); (index=plan.Height) then;// Wtf?; (Plan.Arr [index2, index]=0) then.AddEq (index, index2, data.Arr [index2, index]) ;; {}