#include <stdio.h>
#include <math.h>
void command_zero(double a,double b,double c);
void command_upzero(double a,double b,double c);
void command_downzero(double a,double b,double c);
int main()
{
double a,b,c,flag;
scanf("%lf%lf%lf",&a,&b,&c);
flag=pow(b,2)-4*a*c;
if(flag<0)
command_downzero(a,b,c);
else if(flag>0)
command_upzero(a,b,c);
else
command_zero(a,b,c);
return 0;
}
void command_zero(double a,double b,double c)
{
double x;
x=-b/2*a;
printf("x1=%.3lf x2=%.3lf",x,x);
}
void command_upzero(double a,double b,double c)
{
double x1,x2;
x1=(sqrt(pow(b,2)-4*a*c)-b)/(2*a);
x2=(-sqrt(pow(b,2)-4*a*c)-b)/(2*a);
printf("x1=%.3lf x2=%.3lf",x1,x2);
}
void command_downzero(double a,double b,double c)
{
double flag=sqrt(4*a*c-pow(b,2))/(2*a);
printf("x1=%.3lf+%.3lfii x2=%.3lf-%.3lfi",-b/(2*a),flag,-b/(2*a),flag);
}
0.0分
0 人评分
时间转换 (Java代码)浏览:618 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:694 |
C语言训练-求PI* (C语言代码)浏览:641 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:594 |
用筛法求之N内的素数。 (C语言代码)浏览:685 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:585 |
大家好,我是验题君浏览:604 |
1128题解(返回值为数组的情况)浏览:571 |
C二级辅导-进制转换 (C语言代码)浏览:750 |
整除的尾数 (C语言代码)浏览:856 |