var a,b,t,M,R:integer;
Function F(x: integer):integer;
begin
F := -2*(x+2)*(x-6);
end;
Begin
a := -11; b := 11;
M := a; R:= F(a);
t:=a;
while t < b do
begin
if (F(t)>R) then
begin
M := t;
R:= F(t);
end;
t:=t+2;
end;
write(M);
End.
|
#include<stdio.h>
int F(int x)
{
return(-2*(x+2)*(x-6));
}
int main(void)
{
int a, b, t, M, R;
a = -11; b = 11;
M = a; R= F(a);
t=a;
while (t < b)
{
if (F(t)>R)
{
M = t;
R= F(t);
}
t=t+2;
}
printf(″%d″, M);
}
|
def F(x):
return -2*(x + 2) * (x - 6)
a = -11
b = 12
M = a
R = F(a)
t = a
while (t < b):
if F(t) > R:
M = t
R = F(t)
t = t + 2
print (M) |