double x,y;
int j=0;
for(x=0;x<=1;x=x+0.01)
{
y=0.5*x-0.5*x*x;
j++;
}
printf("%d %lf %lf",j,x,y);
return 0;
double x,y;
int j=0;
for(x=0;x<=1;x=x+0.01)
{
y=0.5*x-0.5*x*x;
j++;
}
printf("%d %lf %lf",j,x,y);
return 0;
x<=1
这个不可靠。因为浮点数有误差
修改为
x<1.000001