题解 | #取近似值#
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
本题没啥难度。不用细说。
#include <cmath>
using namespace std;
int main() {
float n;
int res = 0;
cin >> n;
float rem = 0.0;
rem = n - floor(n);
if (rem >= 0.5) {
res = ceil(n);
} else {
res = floor(n);
}
cout << res;
return 0;
}
查看21道真题和解析