請勿輸出題目未要求的文字: No answer
程式碼import sys
for s in sys.stdin:
try:
a1, b1, c1, a2, b2, c2 = s.split()
delta = int(a1) * int(b2) - int(a2) * int(b1)
delta_x = int(c1) * int(b2) - int(b1) * int(c2)
delta_y = int(a1) * int(c2) - int(c1) * int(a2)
if delta == delta_x == delta_y:
print("Too many")
elif delta != "0":
x = round(int(delta_x) / int(delta) , 2)
y = round(int(delta_y) / int(delta) , 2)
if (x * 100) % 100 != 0 or (y * 100) % 100 != 0:
print("x=" + str(x) + "\ny=" + str(y))
else:
print("x=" + str(x) +"0\ny=" + str(y) + "0")
except:
print("No answer")
break
這題只有一行測資
你用 for s in sys.stdin如果 input 多了一個空白行用 split 會出錯
剛好會執行你的 except 那一段才會多一行輸出