do....while一直输出相同的值
# include<stdio.h># include<math.h>
int main(void)
{
double a, b, c;
double delta;
double x1, x2;
printf("请输入系数的值:\n");
printf("a = ");
scanf("%lf", &a);
printf("b = ");
scanf("%lf", &b);
printf("c = ");
scanf("%lf", &c);
delta = b*b - 4*a*c;
do
{
if (0 == delta)
{
x1 = x2 = (-b) / (2*a);
printf("x1 = x2 = %lf\n", x1, x2);
}
else if (delta > 0)
{
x1 = (-b + sqrt(delta)) / (2*a);
x2 = (-b - sqrt(delta)) / (2*a);
printf("x1 = %lf,x2 = %lf\n", x1, x2);
}
else
{
printf("无解\n");
}
} while (1);
return 0;
}
初学者,还请各位帮忙看下VC++环境下运行的为什么是这个情况,这是我在视频网站上照着输入的,那个视频里面运行的就很正常如图