a,b,c=map(int,input().split())
a=int(a)
b=int(b)
c=int(c)
d=(b^2)-(4*a*c)
if d>0:
x1=(-b+d^0.5)/(2*a)
x2=(-b+d^0.5/(2*a)
print('Two different roots x1=',x1,',x2=',x2)
elif d==0:
x=(-b+d^0.5/(2*a)
print('Two same roots x=',x)
else:
print('No real root')
a,b,c=map(int,input().split())
a=int(a)
b=int(b)
c=int(c)
d=(b^2)-(4*a*c)if d>0:
x1=(-b+d^0.5)/(2*a)
x2=(-b+d^0.5/(2*a)
print('Two different roots x1=',x1,',x2=',x2)elif d==0:
x=(-b+d^0.5/(2*a)
print('Two same roots x=',x)
else:
print('No real root')
小弟我看到三個問題:
1.d>0那邊,x1 和 x2 是一樣的?
2.d>0那邊,x2=(-b+d^0.5/(2*a) 少了一個右括號,應為: x2=(-b+d^0.5)/(2*a)
3.d==0那邊,x=(-b+d^0.5/(2*a) 也少了一個右括號,應為 x=(-b+d^0.5)/(2*a)
a,b,c=map(int,input().split())
a=int(a)
b=int(b)
c=int(c)
d=(b^2)-(4*a*c)if d>0:
x1=(-b+d^0.5)/(2*a)
x2=(-b+d^0.5/(2*a)
print('Two different roots x1=',x1,',x2=',x2)elif d==0:
x=(-b+d^0.5/(2*a))
print('Two same roots x=',x)
else:
print('No real root')