a + b - c / d 為什么是3.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; ? ?//在這里體驗(yàn)哦~
? ? printf("%f\n", result);
? ? return 0;
}
#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; ? ?//在這里體驗(yàn)哦~
? ? printf("%f\n", result);
? ? return 0;
}
2019-07-25
舉報(bào)
2019-07-25
c和d是int型,所以3/4=0,右邊a+b-c/d=3,然后result是double型,發(fā)生隱式轉(zhuǎn)換。所以result=3.000000
2019-07-25
a+b=3,c/d=0,3-0=3,且%f要求6位小數(shù),所以答案為3.000000