Console.WriteLine("求解方程ax^2+bx+c=0的解."); Console.WriteLine("请分别输入a,b,c的值(注意每输入一个值按一下回车):"); double a = double.Parse(Console.ReadLine()); double b = double.Parse(Console.ReadLine()); double c = double.Parse(Console.ReadLine()); * a * c;
#!/usr/bin/python # 导入math包 import math def quadratic(a, b, c): if not isinstance(a, (int, float))and isinstance(a, (int, float)) and isinstance(a, (int, float)): raise TypeError('a or b or c must be a number') dt = int(b) ** 2-(4*int(a)*int(c)) if a
请定义一个函数quadratic(a, b, c),接收3个参数,返回一元二次方程:ax² + bx + c = 0的两个解. #!/usr/bin/env python # -*- coding: utf-8 -*- import math def quadratic(a,b,c): if a == 0: raise TypeError('a不能为0') if not isinstance(a,(int,float)) or not isinstance(b,(int,float)) or n