题解 | #实现四舍五入#
实现四舍五入
https://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
#include <iostream>
using namespace std;
int main() {
double d = 0.0;
int res = 0;
cin >> d;
if (d > 0) {
res = (int)(d + 0.5);
} else {
res = (int)(d - 0.5);
}
cout << res << endl;
}
// 64 位输出请用 printf("%lld")