# python怎么把输出中的减号去掉？

Ghost
• 1

（该问题已解决，第二个为正确代码）

``````import math
n=input().split()
a,b,c=float(n[0]),float(n[1]),float(n[2])
eps=0.000001
if abs(b*b-4*a*c)<eps :
x1 = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
print('x1=x2=%.5f'%x1)
elif b*b>4*a*c:
x1 = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
x2 = (-b - math.sqrt(b * b - 4 * a * c)) / (2 * a)
print('x1=%.5f;x2=%.5f'%(x1,x2))
else:
sb= -b / (2 * a)
xb= math.sqrt(4 * a * c - b * b) / (2 * a)

print('x1=%.5f+%.5fi;x2=%.5f-%.5fi'%(sb,xb,sb,xb))``````
``````import math
n=input().split()
a,b,c=float(n[0]),float(n[1]),float(n[2])
eps=0.000001
if abs(b*b-4*a*c)<eps :
x1 = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
print('x1=x2=%.5f'%x1)
elif b*b>4*a*c:
x1 = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)
x2 = (-b - math.sqrt(b * b - 4 * a * c)) / (2 * a)
print('x1=%.5f;x2=%.5f'%(x1,x2))
else:
sb= -b / (2 * a)
xb= math.sqrt(4 * a * c - b * b) / (2 * a)
if abs(sb)<eps:
sb=0

print('x1=%.5f+%.5fi;x2=%.5f-%.5fi'%(sb,xb,sb,xb))``````

###### 你尚未登录，登录后可以
• 和开发者交流问题的细节
• 关注并接收问题和回答的更新提醒
• 参与内容的编辑和改进，让解决方法与时俱进