为什么这个程序会error C2181: 没有匹配 if 的非法 else
#include#includeintmain(void){inta=1;intb=2;intc=3;floatdelta;floatx1;floatx2;delta=b...
# include
# include
int main(void) { int a = 1; int b = 2; int c = 3; float delta; float x1; float x2; delta = b*b - 4a*c; } { if (deta > o) { x1 = (-b + sqrt(delta)) / 2*a; x2 = (-b - sqrt(delta)) / 2*a; printf("一元二次方程的解是 %f\n, %f\n",x1,x2); } else if (delta == 0); { x1 = x2; x2 = (-b ) / 2*a; printf("一元二次方程的解是 %f\n",x1); } else { printf("无解",); } return 0 }
# include <stdio.h>
# include <math.h>
int main(void)
{
int a = 1;
int b = 2;
int c = 3;
float delta;
float x1;
float x2;
delta = b*b - 4a*c;
}
{
if (deta > o)
{
x1 = (-b + sqrt(delta)) / 2*a;
x2 = (-b - sqrt(delta)) / 2*a;
printf("一元二次方程的解是 %f\n, %f\n",x1,x2);
}
else if (delta == 0);
{
x1 = x2;
x2 = (-b ) / 2*a;
printf("一元二次方程的解是 %f\n",x1);
}
else
{
printf("无解",);
}
return 0
} 展开
# include
int main(void) { int a = 1; int b = 2; int c = 3; float delta; float x1; float x2; delta = b*b - 4a*c; } { if (deta > o) { x1 = (-b + sqrt(delta)) / 2*a; x2 = (-b - sqrt(delta)) / 2*a; printf("一元二次方程的解是 %f\n, %f\n",x1,x2); } else if (delta == 0); { x1 = x2; x2 = (-b ) / 2*a; printf("一元二次方程的解是 %f\n",x1); } else { printf("无解",); } return 0 }
# include <stdio.h>
# include <math.h>
int main(void)
{
int a = 1;
int b = 2;
int c = 3;
float delta;
float x1;
float x2;
delta = b*b - 4a*c;
}
{
if (deta > o)
{
x1 = (-b + sqrt(delta)) / 2*a;
x2 = (-b - sqrt(delta)) / 2*a;
printf("一元二次方程的解是 %f\n, %f\n",x1,x2);
}
else if (delta == 0);
{
x1 = x2;
x2 = (-b ) / 2*a;
printf("一元二次方程的解是 %f\n",x1);
}
else
{
printf("无解",);
}
return 0
} 展开
1个回答
展开全部
int main(void)
{
int a = 1;
int b = 2;
int c = 3;
float delta;
float x1;
float x2;
delta = b*b - 4a*c;
if (deta > o)
{
x1 = (-b + sqrt(delta)) / 2*a;
x2 = (-b - sqrt(delta)) / 2*a;
printf("一元二次方程的解是 %f\n, %f\n",x1,x2);
return 0;
}
if (delta == 0)
{
x1 = x2;
x2 = (-b ) / 2*a;
printf("一元二次方程的解是 %f\n",x1);
return 0;
}
if(deta<0)
{
printf("无解",);
}
return 0;
}
{
int a = 1;
int b = 2;
int c = 3;
float delta;
float x1;
float x2;
delta = b*b - 4a*c;
if (deta > o)
{
x1 = (-b + sqrt(delta)) / 2*a;
x2 = (-b - sqrt(delta)) / 2*a;
printf("一元二次方程的解是 %f\n, %f\n",x1,x2);
return 0;
}
if (delta == 0)
{
x1 = x2;
x2 = (-b ) / 2*a;
printf("一元二次方程的解是 %f\n",x1);
return 0;
}
if(deta<0)
{
printf("无解",);
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询