题解 | #实现四舍五入#
实现四舍五入
https://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
#include <stdio.h>
int main()
{
double a =0; //浮点型字符
scanf("%lf",&a); //输入字符
if(a>0) //判断大小
printf("%d\n",(int)(a+0.5)); //正数取整
else
printf("%d\n",(int)(a-0.5)); //负数取整
return 0;
}
int main()
{
double a =0; //浮点型字符
scanf("%lf",&a); //输入字符
if(a>0) //判断大小
printf("%d\n",(int)(a+0.5)); //正数取整
else
printf("%d\n",(int)(a-0.5)); //负数取整
return 0;
}