#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 人评分
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1212 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:1302 |
WU-蓝桥杯算法提高VIP-交换Easy (C++代码)浏览:1180 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:586 |
简单的a+b (C语言代码)浏览:449 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:648 |
矩形面积交 (C语言代码)浏览:1424 |
盐水的故事 (C语言代码)浏览:1578 |
小O的数字 (C++代码)浏览:803 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:728 |