請問為什么用float定義還不對啊
#include <stdio.h>
int main()
{
? float a,b,c,d;
? ? double result;
? ? a = 1;
? ? b = 2;
? ? c = 3;
? ? d = 4;
? ? result = a + b- c/d;? ? //在這里體驗哦~
? ? printf("%.f\n", result);
? ? return 0;
}
請問為什么結(jié)果是2啊,我明明ABCD是用float定義的
#include <stdio.h>
int main()
{
? float a,b,c,d;
? ? double result;
? ? a = 1;
? ? b = 2;
? ? c = 3;
? ? d = 4;
? ? result = a + b- c/d;? ? //在這里體驗哦~
? ? printf("%.f\n", result);
? ? return 0;
}
請問為什么結(jié)果是2啊,我明明ABCD是用float定義的
2020-04-07
舉報
2020-11-25
%f? ?輸出而不是? %.f,
2020-09-25
為什么要用float定義?。縜bcd不是就該用int的嗎?雖然這樣結(jié)果不止小數(shù)
2020-04-07
我明白了,是應(yīng)該用%f輸出而不是? %.f吧