题目要求一行输入多个数,要用split分割
a,b,c,d,e,f=input().split(',')
a=float(a)
b=float(b)
c=float(c)
d=float(d)
e=float(e)
f=float(f)
if a*d-b*c==0:
print('The equation has no solution')
else:
x=(e*d-b*f)/(a*d-b*c)
y=(a*f-e*c)/(a*d-b*c)
print("x=%.1f y=%.1f"%(x,y))
这么写,a,b,c,d,e,f都是字符串,不是整数啊
改成a = int(input())这样子
input()得到的是字符串,你需要用int转成整数再进行计算,修改如下:
a= int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())
f= int(input())
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!