解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<math.h>
int main()
{
void delta_day_0(double delta, double a, double b, double c);
void delta_dy_0(double delta, double a, double b, double c);
void delta_xy_0(double delta, double a, double b, double c);
double a, b, c, delta;
scanf("%lf %lf %lf", &a, &b, &c);
delta = pow(b,2) - 4 * a * c;
if (delta > 0)delta_day_0(delta, a, b, c);
else if (delta == 0)delta_dy_0(delta,a,b,c);
else if (delta < 0)delta_xy_0(delta,a,b,c);
return 0;
}
void delta_day_0(double delta,double a, double b, double c)
{
double x1, x2;
x1 =(b + sqrt(delta)) /( (-2)*a);
x2 = (b - sqrt(delta))/ ((-2) * a);
printf("x1=%.3lf x2=%.3lf", x1, x2);
}
void delta_dy_0(double delta, double a, double b, double c)
{
double x1, x2;
x1=x2=(b + sqrt(delta) )/ ((-2) * a);
printf("x1=%.3lf x2=%.3lf", x1, x2);
}
void delta_xy_0(double delta, double a, double b, double c)
{
double x1,x1i, x2,x2i;
x1 = b / ((-2) * a);
x1i = sqrt(-delta) / ((-2) * a);
x2 = b / ((-2) * a);
x2i =-sqrt(-delta) / ((-2) * a);
printf("x1=%.3lf+%.3lfi x2=%.3lf%.3lfi", x2, x2i, x1, x1i);
}
0.0分
0 人评分