技術討論區 > C/C++程式設計討論區
請教C語言問題
(1/1)
student f:
程式碼如下,我預設讓y不等於零的時候輸出,請問為什麼y等於零時也會輸出 ???
#include <stdio.h>
#include <math.h>
#include <time.h>
int main()
{
while(1)
{
double a,b,c,x;
double start,end,d;
double y;
printf("input a,b,c:");
scanf("%lf %lf %lf",&a,&b,&c);
printf("input start,end,d:");
scanf("%lf %lf %lf",&start,&end,&d);
end+=d;
for(x=start; x<end; x+=d)//from x to end
{
y=a*x*x+b*x+c;
if(y!=0)
{
printf("x=%lf\t",x);
printf("y=%lf\n",y);
}
}
printf("\n");
}
}
twu2:
因為只印出小數點後六位, 實際上後面還有.
student f:
太感謝了,
我朝小數點後這個方向去網路上找,
發現判斷浮點數不能用和整數行相同的方式,
之後也成功了,謝謝您的回覆 :) :)
導覽
[0] 文章列表
前往完整版本