我已经建立了一个计算二次方程并找到解决方案的项目。我已经输入了
a
,
b
和
c
. 当我输入这些值时,就会出现完整的二次方程。例如我输入
a:2
,
b:3
,
c:4
,看起来
2x2+3x+4
. 现在的问题是负数。如果我给
乙
价值
-3
和
c类
价值
-4
,二次方程如下:
2x2+-3x+-4
. 现在我希望它以这种形式出现:
2x2+(-3)x+(-4)
. 有人能帮忙吗?
这是我的代码:
a=int(input("Enter the value of a:"))
b=int(input("Enter the value of b:"))
c=int(input("Enter the value of c:"))
d = b**2-(4*a*c)
if b>0 and c>0:
print("The quadratic equation is : " + str(a) + "x2+" + str(b) + "x+" + str(c))
elif b<0 and c<0:
print("The quadratic equation is : " + str.format(a) + "x2+" + str(b) + "x+" + str(c))