您的程式被監控系統中斷,可能是程式無法正常結束所導致。 Traceback (most recent call last): File "/11244278/code_11244278.py", line 2, in root1=int((-b+(b**2-4*a*c)**0.5)//(2*a)) TypeError: can't take floor of complex number.
a,b,c=map(int,input().split())root1=int((-b+(b**2-4*a*c)**0.5)//(2*a))root2=int((-b-(b**2-4*a*c)**0.5)//(2*a))if (b**2-4*a*c>0):print("Two different roots x1=",root1," , x2=",root2,sep="")elif (b**2-4*a*c==0):print("Two same roots x=",root1,sep="")else:print("No real root")您的程式被監控系統中斷,可能是程式無法正常結束所導致。 Traceback (most recent call last): File "/11244278/code_11244278.py", line 2, in root1=int((-b+(b**2-4*a*c)**0.5)//(2*a)) TypeError: can't take floor of complex number.
先判斷b**2-4*a*c是否小於0