C语言的调试问题

来源:百度知道 编辑:UC知道 时间:2024/06/01 06:08:04
#include"math.h"
main()
{float fx(float a);
float a=-10,b=10,x;
whlie(fabs(a-b)>=1e-6)
{ x=(a+b)/2;
if(fx(x)*fx(a)>=0) a=x;
else b=x;
printf("%f",x);
getch();
} }
float fx(float a)
{ float y;
y=2*a*a*a-4*a*a+3*a-6;
return(y);
}
在调试中说是第6行缺少分号

#include"math.h"
#include <stdio.h>
#include <conio.h>
main()
{float fx(float a);
float a=-10,b=10,x;
while(fabs(a-b)>=1e-6)
{ x=(a+b)/2;
if(fx(x)*fx(a)>=0) a=x;
else b=x;
printf("%f",x);
getch();
} }
float fx(float a)
{ float y;
y=2*a*a*a-4*a*a+3*a-6;
return(y);
}
错误如下:
1.while写错了
2.使用getch()要包含文件conio.h
3.使用printf()要包含文件stdio.h

大哥,你将while写成whlie,能不出错吗?