C语言,一个浮点数,怎么四舍五入保留到个位数

如题所述

int Function(float yournum)
{
int temp= yournum*10;
int floatPart=temp%10;
int intPart=temp/10;
if(floatPart>=5)
{
return intPart+1;
}
return intPart;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-01-22
Math

floor

~