题目内容:
你可以使用克莱姆法则解下面的线性方程2x2系统:
编写程序,用户输入a、b、c、d、e和f,然后显示x和y的结果。如果ad-bc为零,呈现“The equation has no solution”。
输入格式:
a、b、c、d、e和f的值(逗号分隔)
输出格式:
x和y的值(空格分隔,小数点后保留1位)
输入样例:
1.0,2.0,2.0,4.0,4.0,5.0
输出样例:
The equation has no solution
a,b,c,d,e,f==map(float(input()),sep=',')
if ad-bc!=0:
x=(ed-bf)/(ad-bc)
y=(af-ec)/(ad-bc)
print(x,y)
else:
print('The equation has no solution')
结果显示错误:程序报错 exit code 非0
不太清楚赋值是否正确 或者是哪块出现问题
a,b,c,d,e,f=eval(input())
if a*d-b*c!=0:
x=(e*d-b*f)/(a*d-b*c)
y=(a*f-e*c)/(a*d-b*c)
print(x,y)
else:
print('The equation has no solution')
如有帮助,希望点一下下采纳
第一句赋值就错了
a,b,c,d,e,f==map(float(input()),sep=',')
这两个等号是比较啊
直接改成
a,b,c,d,e,f=eval(input())