C语言计算一元二次方程的根.求指出错误#include #include int main(void){float a,b,c,d,x1,x2;char ans;printf("Enter the coefficients of the quadratic equation>");scanf("%f\t%f\t%f",&a,&b,&c);if(a =0 && d >=0){d=pow(b,2)-4*a*c;x1=(-b+sqrt
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/06 10:40:56
![C语言计算一元二次方程的根.求指出错误#include #include int main(void){float a,b,c,d,x1,x2;char ans;printf(](/uploads/image/z/8452878-6-8.jpg?t=C%E8%AF%AD%E8%A8%80%E8%AE%A1%E7%AE%97%E4%B8%80%E5%85%83%E4%BA%8C%E6%AC%A1%E6%96%B9%E7%A8%8B%E7%9A%84%E6%A0%B9.%E6%B1%82%E6%8C%87%E5%87%BA%E9%94%99%E8%AF%AF%23include+%23include+int+main%28void%29%7Bfloat+a%2Cb%2Cc%2Cd%2Cx1%2Cx2%3Bchar+ans%3Bprintf%28%22Enter+the+coefficients+of+the+quadratic+equation%3E%22%29%3Bscanf%28%22%25f%5Ct%25f%5Ct%25f%22%2C%26a%2C%26b%2C%26c%29%3Bif%28a+%3D0+%26%26+d+%3E%3D0%29%7Bd%3Dpow%28b%2C2%29-4%2Aa%2Ac%3Bx1%3D%28-b%2Bsqrt)
C语言计算一元二次方程的根.求指出错误#include #include int main(void){float a,b,c,d,x1,x2;char ans;printf("Enter the coefficients of the quadratic equation>");scanf("%f\t%f\t%f",&a,&b,&c);if(a =0 && d >=0){d=pow(b,2)-4*a*c;x1=(-b+sqrt
C语言计算一元二次方程的根.
求指出错误
#include
#include
int main(void)
{
float a,b,c,d,x1,x2;
char ans;
printf("Enter the coefficients of the quadratic equation>");
scanf("%f\t%f\t%f",&a,&b,&c);
if(a =0 && d >=0)
{
d=pow(b,2)-4*a*c;
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("x1=%f\tx2=%f",x1,x2);
printf("Do you want to solve another quadratic equation(y/n)?>");
fflush(stdin);
scanf("%c",&ans);
}
else
{
prinft("wrong");
}
return(0);
}
gcc -lm 1.c 之后
出现如下问题
看不懂
Undefined first referenced
symbol in file
prinft /var/tmp//ccEWqWlc.o
ld:fatal:Symbol referencing errors.No output written to a.out
collect2:ld returned 1 exit status
C语言计算一元二次方程的根.求指出错误#include #include int main(void){float a,b,c,d,x1,x2;char ans;printf("Enter the coefficients of the quadratic equation>");scanf("%f\t%f\t%f",&a,&b,&c);if(a =0 && d >=0){d=pow(b,2)-4*a*c;x1=(-b+sqrt
/*结束程序请按“Ctrl+z”*/
#include
#include
int main()
{
float a, b, c;
double d, x1, x2;
printf("Enter the coefficients of the quadratic equation>\n");
while(scanf("%f\t%f\t%f", &a, &b, &c)!=EOF)
{
double d;
d=pow(b,2)-4*a*c;
if((a!=0&&d>=0)!=EOF)
{
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("x1=%lf\tx2=%lf\n", x1, x2);
}
printf("Enter the coefficients of the quadratic equation>\n");
}
return 0;
}