酷!學園
技術討論區 => 程式討論版 => C/C++程式設計討論區 => 主題作者是: student f 於 2021-04-01 15:20
-
程式碼如下,我預設讓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");
}
}
-
因為只印出小數點後六位, 實際上後面還有.
-
太感謝了,
我朝小數點後這個方向去網路上找,
發現判斷浮點數不能用和整數行相同的方式,
之後也成功了,謝謝您的回覆 :) :)