题解 | #实现四舍五入#
实现四舍五入
http://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
#include using namespace std;
int main() { double a = 0; double b = 0;
cin >> a;
b = a * 10;
a = (int)a;
b = (int)b % 10;
if (a >= 0)
{
if (b >= 5)
cout << a+1 << endl;
else
cout << a << endl;
}
else
{
if (b <= -5)
cout << a-1 << endl;
else
cout << a << endl;
}
return 0;
}