var a,b,t,M,R:integer;
Function F(x:integer):integer;
begin
F:= x*x - 8*x + 10;
end;
BEGIN
a:=-5; b:=5;
M:=a; R:=F(a);
for t:=a to b do begin
if (F(t)> R)then begin
M:=t;
R:=F(t);
end;
end;
write(R);
END.
|
#include<stdio.h>
int a,b,t,M,R;
int F(int x);
{
return x*x - 8*x + 10;
}
main()
{
a = -5; b = 5;
M = a; R = F(a);
for(t=a; t<=b; t++) {
if (F(t)> R) {
M = t;
R = F(t);
}
}
printf(«%d»,R);
}
|
def F(x):
return x*x - 8*x +10
a = -5
b = 5
M = a
R = F(a)
for t in range (a, b+1):
if F(t) > R:
M = t
R = F(t)
print (R) |