# include≤ stdio h> include <math.h> int main o double a, b, c, disc,x1,x2, p, qi scanf("%/lfo/lf%/lf",&a, &b, &c); 631 disc=b*b-4aCi 计算b24ac,disc的值变为-15
#include <stdio.h> #include <math.h> int main ( ) { double a,b,c,disc,x1,x2,p,q; scanf("%lf%lf%lf",&a,&b,&c); disc=b*b-4*a*c; 计算b2 -4ac,disc的值变为-15
if(disc<0)-15<0为真 printf( has not real roots\n else has not real roots {p=-b/(2.0*a) g=sqrt(disc)/(2.0*ai x1=p+gi X2=p-gi printf( real roots:\nx1=%07.2f\n x2=%72fn"x1X2) return o
if (disc<0) printf(“has not real roots\n”); else { p=-b/(2.0*a); q=sqrt(disc)/(2.0*a); x1=p+q; x2=p-q; printf(“real roots:\nx1=%7.2f\n x2=%7.2f\n”,x1,x2); } return 0; } -15<0为真
# include≤ stdio h> include <math.h> int main o double a, b, c, disc,x1,x2, p, qi scanf("/lf/lf%/olf", &a, &b, &c);241 disc=b*b-4aCi 计算b2-4ac,disc的值变为8
#include <stdio.h> #include <math.h> int main ( ) { double a,b,c,disc,x1,x2,p,q; scanf("%lf%lf%lf",&a,&b,&c); disc=b*b-4*a*c; 计算b2 -4ac,disc的值变为8
if(disc<0)8<0为假 printf( has not real roots\n i else p=b/(2.0*a);p的值变为-1 q=sqrt(disc)/(20*a);q的值变为071 X1=p+qX1的值变为029 x2=p-qx2的值变为-171 printf( real roots:(nx1=%/07.2f\n x2=%72fn"x1X2); real roots: return o 1=-8.29 2 1.71
if (disc<0) printf(“has not real roots\n”); else { p=-b/(2.0*a); q=sqrt(disc)/(2.0*a); x1=p+q; x2=p-q; printf(“real roots:\nx1=%7.2f\n x2=%7.2f\n”,x1,x2); } return 0; } 8<0为假 p的值变为-1 q的值变为0.71 x1的值变为-0.29 x2的值变为-1.71
if (disc<o) printf( has not real roots\n i else p=-b/(20*a) g=sqrt(disc)/(2.0*ai x1=p+gi X2=p-gir printf( real roots: \nx1=%07.2f\n x2=%72f\n"rx1x2); return o 选择结构,用i语句实现的
if (disc<0) printf(“has not real roots\n”); else { p=-b/(2.0*a); q=sqrt(disc)/(2.0*a); x1=p+q; x2=p-q; printf(“real roots:\nx1=%7.2f\n x2=%7.2f\n”,x1,x2); } return 0; } 选择结构,用if语句实现的