c语言上机答案 (2).zip
立即下载
资源介绍:
c语言上机答案 (2).zip
#include
#include
void root(double a, double b, double c)
{ /************begin************/
double delta,x1,x2,m,n;
if (fabs(a) <= 1e-6){
if (fabs(b) <= 1e-6)
puts("Not an equation");
else
printf("x=%.2lf",-c/b);
return;
}
else{
delta=b*b - 4*a*c;
m = -b / (2*a);
n = sqrt(fabs(delta)) / (2*a);
x1 = m + n;
x2 = m - n;
if (fabs(delta) <= 1e-6)
printf("x1=%.2lf, x2=%.2lf", x1, x1);
else if (delta < 0)
printf("x1=%.2lf+%.2lfi, x2=%.2lf-%.2lfi",m,n,m,n);
else
printf("x1=%.2lf, x2=%.2lf", x1, x2);
}
/************end************/
}
int main( )
{ double a,b,c;
scanf("%lf%lf%lf",&a,&b,&c);
root(a,b,c);
printf("\n");
return 0;
}
资源文件列表:
c语言上机答案 (2).zip 大约有234个文件