#40969: 第一個一直沒過


moyao0907349805@gmail.com (阿維)

學校 : 不指定學校
編號 : 273912
來源 : [39.9.194.124]
最後登入時間 :
2025-05-09 22:38:28

a,b,c=map(int, input().split())
r=b**2-4*a*c
if r>0:
    x1 = int((b*-1+r**0.5)/(2*a))
    x2 = int((b*-1-r**0.5)/(2*a))
if x1>x2:
    print("Two different roots x1=%d , x2=%d" % (x1, x2))
elif x2>x1:
    print("Two different roots x2=%d , x1=%d" % (x2, x1))
elif x1==x2:
    print("Two same roots x=%d" % x1)
else:
    print("No real root")

#40996: Re: 第一個一直沒過


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [39.12.66.21]
最後登入時間 :
2025-04-20 17:19:22

1.
if r>0:
2.
if x1>x2:
    print("Two different roots x1=%d , x2=%d" % (x1, x2))
elif x2>x1:
    print("Two different roots x2=%d , x1=%d" % (x2, x1))
elif x1==x2:
    print("Two same roots x=%d" % x1)

1. 改成r>=0

2. 這6行縮排

 

#41001: Re: 第一個一直沒過


moyao0907349805@gmail.com (阿維)

學校 : 不指定學校
編號 : 273912
來源 : [39.9.194.124]
最後登入時間 :
2025-05-09 22:38:28

1.
if r>0:
2.
if x1>x2:
    print("Two different roots x1=%d , x2=%d" % (x1, x2))
elif x2>x1:
    print("Two different roots x2=%d , x1=%d" % (x2, x1))
elif x1==x2:
    print("Two same roots x=%d" % x1)

1. 改成r>=0

2. 這6行縮排

 

還是沒過 它顯示"name 'x1' is not defined"



#41072: Re: 第一個一直沒過


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [39.12.66.21]
最後登入時間 :
2025-04-20 17:19:22

還是沒過 它顯示"name 'x1' is not defined"




你把改好的程式碼貼上來,我看還有哪邊有問題