(int)x*0.5;
In this case, only the x value is rounded, and the type is not converted. The rounded number is then multiplied by 0.5.
Let’s look at the title first:
double x=5.5,(int)X*0.5
请问这时的x=?
int main()
{
double x=5.5;
x=(int)x*0.5;//对x的初值进行取整,不对类型进行转换
printf("x=%0.1lf",x);//0.1只获取到小数点后一位数
return 0;
}
The result is:
x=2.5