程式碼如下
明明測試都過了
送出解答的最後一個測資卻算錯了
while True :try :a,b,c=input().split()except :breaka=int(a)b=int(b)c=int(c)D=(b*b-4*a*c)t=pow(D,0.5)x3=(-b+t)/2*ax4=(-b-t)/2*aif D>0 :print('Two different roots x1=%d , x2=%d' % (x3,x4) )elif D==0 :print('Two same roots x=%d' % x4)elif Dprint('No real root')elif b==0 and c==0 :print('Two same roots x=0')
2*a 要括號,這樣: (2*a),沒有括號就是除以2再乘以a,有括號才是除以2a喔 :)