|
|
back to boardPlease help me to find a mistake my program is : var x, y:real; x0, y0 : integer; a, b : real; count,i : integer; Max, Temp : real; Function f(x,y : real) : real; begin f:=a*x+b*y-x*x-y*y; end; BEGIN x0:=0; y0:=0; Max := -99999999; Readln(a,b); readln(count); x := a/2; y := b/2; x:=trunc(x); y:=trunc(y); x0:=round(x); y0:=round(y); if (x+y)<=count then begin max:=f(x,y); if ( (x+1+y)<=count) and (max<f(x,y+1)) then begin y0:=round(y+1); max:=f(x,y0); end; if ((x+1+y)<=count) and (f(x+1,y)>max) then begin x0:=round(x+1); max:=f(x0,y); end; end else begin for i:=0 to count do begin x:=i; y:= count-x; if f(x,y)>max then begin x0:=round(x); y0:=round(y); max:=f(x0,y0); end; end; end; max := f(x0,y0); if (x0<0) and (y0<0) then begin x0 := 0; y0 := 0; max := 0; end; Writeln(max:1:2); Writeln(x0,' ',y0); END. |
|
|