为什么在下面的代码片段中呢?
int a = 7; int b = 3; double c = 0; c = a / b;
c最终得到的值是2,而不是2.3333,正如人们所期望的那样.如果a和b双打,答案就变成2.333.但肯定是因为c 已经是双重它本来应该使用整数?
c
a
b
那怎么来int/int=double不行?
int/int=double
c++ variables double integer-division
c++ ×1
double ×1
integer-division ×1
variables ×1