C语言实验——一元二次方程Ⅰ
#include <stdio.h> #include <math.h> double zxd (int a, int b, int c); double dxz (int a, int b, int c); int main() { int a, b, c; double t; scanf("%d %d %d", &a, &b, &c); double x1 = zxd(a, b, c); double x2 = dxz(a, b, c); if(x1 < x2) { t = x1; x1 = x2; x2 = t; } printf("%.2lf %.2lf\n",x1, x2); return 0; } double zxd(int a, int b, int c) { double x1; x1 = (-b+sqrt(b*b-4*a*c))/(2*a); return x1; } double dxz(int a, int b, int c) { double x2; x2 = (-b-sqrt(b*b-4*a*c))/(2*a); return x2; }