题解 | #实现四舍五入#
实现四舍五入
https://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
#include <cmath> #include <iostream> using namespace std; int main() { double a; while (cin >> a) { // 注意 while 处理多个 case if(a > 0){ cout<<(int)(a + 0.5); } else{ cout<<(int)(a - 0.5); } } }