当我为a和b输入0时,Cramer的Rule python程序崩溃了

时间:2016-02-29 22:34:10

标签: python python-3.x

如果我为0a输入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)

0 个答案:

没有答案