a = -20
b = -20
end = False
nec = 0
while a < 10:
a = round(a+0.001, 4)
b =1
while b < 10:
b = round(b+0.001, 4)
cc = a+2*a*b+b
if cc == 8 or 0<8-cc<0.00001:
print(f"近似结果a:{round(a, 2)},b:{round(b, 2)}")
print(round(cc, 2))
print(round(a+b, 2))
end = True
break
nec = nec+1
if nec>1000:
print(111)
nec = 0
if end:
break
a = -20
b = -20
end = False
nec = 0
while a < 10:
a = round(a+0.001, 4)
b =1
while b < 10:
b = round(b+0.001, 4)
cc = a+2*a*b+b
if cc == 8 :
print(f"结果a:{round(a, 2)},b:{round(b, 2)}")
print(round(cc, 2))
print(round(a+b, 2))
end = True
break
nec = nec+1
if nec>1000:
print(111)
nec = 0
if end:
break
Comments NOTHING