C语言编程初学,求大佬指明错误!
#include<stdio.h>#include<math.h>intmain(){doublea,b,c,disc,x1,x2,realpart,imagpart;s...
#include <stdio.h>
#include <math.h>
int main()
{
double a,b,c,disc,x1,x2,realpart,imagpart;
scanf("%lf,%lf,%lf",&a,&b,&c);
printf("The equation ");
if(fabs(a)<=1e-6)
printf("is not a quadratic\n");//10
else
{
disc=b*b-4*a*c;
if(fabs(disc)<=1e-6)
printf("has two equal roots:");
printf("x1=x2=%8.4f",-b/(2*a));
else
if(disc>1e-6)
{
x1=(-b-sqrt(disc))/(2*a);//20
x2=(-b sqrt(disc))/(2*a);
printf("has two distinct roots:x1=%6.2lf x2=%6.2lf",x1,x2);
}
else
{
realpart=-b/(2*a);
imagpart=sqrt(-disc)/(2*a);
printf("has two complex roots:\n");
printf("x1=%8.4f-%8.4fi\n",realpart,imagpart);
printf("x2=%8.4f %8.4fi\n",realpart,imagpart);
}
}
rerurn 0;
}
(完了)
它说是18:error:identifier expected 展开
#include <math.h>
int main()
{
double a,b,c,disc,x1,x2,realpart,imagpart;
scanf("%lf,%lf,%lf",&a,&b,&c);
printf("The equation ");
if(fabs(a)<=1e-6)
printf("is not a quadratic\n");//10
else
{
disc=b*b-4*a*c;
if(fabs(disc)<=1e-6)
printf("has two equal roots:");
printf("x1=x2=%8.4f",-b/(2*a));
else
if(disc>1e-6)
{
x1=(-b-sqrt(disc))/(2*a);//20
x2=(-b sqrt(disc))/(2*a);
printf("has two distinct roots:x1=%6.2lf x2=%6.2lf",x1,x2);
}
else
{
realpart=-b/(2*a);
imagpart=sqrt(-disc)/(2*a);
printf("has two complex roots:\n");
printf("x1=%8.4f-%8.4fi\n",realpart,imagpart);
printf("x2=%8.4f %8.4fi\n",realpart,imagpart);
}
}
rerurn 0;
}
(完了)
它说是18:error:identifier expected 展开
1个回答
展开全部
#include <stdio.h>
#include <math.h>
int main()
{
double a, b, c, disc, x1, x2, realpart, imagpart;
scanf("%lf,%lf,%lf", &a, &b, &c);
printf("The equation ");
if (fabs(a) <= 1e-6)
printf("is not a quadratic\n"); // 10
else
{
disc = b * b - 4 * a * c;
if (fabs(disc) <= 1e-6)
{//<===============
printf("has two equal roots:");
printf("x1=x2=%8.4f", -b / (2 * a));
}//<===============
else if (disc > 1e-6)
{
x1 = (-b - sqrt(disc)) / (2 * a); // 20
x2 = (-b + sqrt(disc)) / (2 * a);//<==============
printf("has two distinct roots:x1=%6.2lf x2=%6.2lf", x1, x2);
}
else
{
realpart = -b / (2 * a);
imagpart = sqrt(-disc) / (2 * a);
printf("has two complex roots:\n");
printf("x1=%8.4f-%8.4fi\n", realpart, imagpart);
printf("x2=%8.4f %8.4fi\n", realpart, imagpart);
}
}
return 0;//<============
}
追问
已采纳!感谢!我一直用的是手机版的C编辑器,Visual C 6.0和我的windows7不兼容。。如果你有兼容的软件的话麻烦发一下好嘛(或者告诉我个网址我自己下。。。)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询