這個答案有點不對勁啊
#include <stdio.h>
int main()
{
? ? int 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;
}
運行結果:4.000000
#include <stdio.h>
int main()
{
? ? int 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;
}
運行結果:4.000000
2020-11-21
舉報
2021-10-23
整形除以整形得到整形,所以1/2=0
2020-11-24
C語言及許多計算機語言在進行整數除法時執行舍位,結果中的所有小數部分都會被舍棄,所以1/2=0,3*0=0,所以你的運行結果為4
2020-11-21
不應該是5.5嘛?