刚学c,第二个东西··晒出来!!!!
程序代码:
/*一个解一元二次方程输入a,b,c求x1和x2!!!!*/ # include <stdio.h> # include <math.h> int main(void) { double a, b, c, x1, x2, derta; printf ("请输入二次方程的系数a,b,c用回车键隔开\n"); scanf ("%lf%lf%lf",&a,&b,&c); derta = b*b - 4*a*c; if (derta >= 0) { x1 = (-b + sqrt(derta)) / 2*a; x2 = (-b + sqrt(derta)) / 2*a; printf ("x1的值是:%lf\n",x1); printf ("x2的值是:%lf\n",x2); } else printf ("次方程无解!!!\n"); return 0; }