Discuss / Python / 交作业

交作业

Topic source

iLiliP

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-
import math

a=int(input())
b=int(input())
c=int(input())
s=b*b-4*a*c

if s>=0:
    def quadratic(a, b, c):
        x1=(-b+math.sqrt(b*b-4*a*c))/(2*a)
        x2=(-b-math.sqrt(b*b-4*a*c))/(2*a)
        return x1,x2

    x1,x2=quadratic(a,b,c)
    print(x1,x2)
else:
    print('无解')

  • 1

Reply