正在加载图片...
例求ax2+bx+c=0方程的根,设b2-4ac>0 b 4a #include <stdio. h> #include <math.h> main float a b c, disc, x l, X2, p, q> scanf(a=%f, b=%f, c=%f", &a, &b, &c) disc=b*b-4a*c p=-b/(2*a); q=sqrt(disc)(2*a) XIPtg X2-p-q printf("nInx 52fnx2=%5.2fn",x1,x2) 输入:a=1,b=3c= 输出:x1=1.00 X2=2.00#include <stdio.h> #include <math.h> main() { float a,b,c,disc,x1,x2,p,q; scanf("a=%f,b=%f,c=%f",&a,&b,&c); disc=b*b-4*a*c; p=-b/(2*a); q=sqrt(disc)/(2*a); x1=p+q; x2=p-q; printf("\n\nx1=%5.2f\nx2=%5.2f\n",x1,x2); } 输入:a=1,b=3,c=2  输出:x1=-1.00 x2=-2.00
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有