如果我为0
和a
输入b
,程序会崩溃。我仍在试图弄清楚如何修改它。
a = int(input("Enter number for a: "))
b = int(input("Enter number for b: "))
c = int(input("Enter number for c: "))
d = int(input("Enter number for d: "))
e = int(input("Enter number for e: "))
f = int(input("Enter number for f: "))
x = (e*d-b*f)/(a*d-b*c)
y = (a*f-e*c)/(a*d-b*c)
if a*d-b*c==0:
print("The equation has no solution")
else:
print("x is: ", x, "and y is: ", y)