05.c

来自「学习c语言时的一些例程」· C语言 代码 · 共 21 行

C
21
字号
#include <math.h>
void main()
{float a,b,c,x1,x2,disc;
printf("input a b c:");
scanf("%f,%f,%f",&a,&b,&c);
if(fabs(a)<1e-6)
printf("\nthe equation is not a quadratic");
else
{disc=b*b-4*a*c;
if (disc<0)
printf("\nthe equation has not roots");
else
if(fabs(disc)<1e-6)
printf("\nthe equation has two roots:%8.4f",-b/(2*a));
else
{x1=(-b+sqrt(disc)/2*a);
 x2=(-b-sqrt(disc)/2*a);
 printf("\nthe equation has distinct real roots:%8.4f,%8.4f",x1,x2);
 }
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?