import math
def quadratic(a,b,c): if b*b-4*a*c<0: return "无解" elif a==0: return -c/b else: return (-b+math.sqrt(b*b-4*a*c))/a/2,(-b-math.sqrt(b*b-4*a*c))/a/2
s1=quadratic(1,3,-4) print(s1)
s2=quadratic(1,1,1) print(s2)
s3=quadratic(1,4,4) print(s3)
s4=quadratic(1,5,4) print(s4)
|
请发表评论