题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
//取近似值
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double number;
cin >> number;
// 四舍五入到最接近的整数
int rounded = round(number);
cout << rounded << endl;
return 0;
}
//直接调用cmath库中的round()函数


查看9道真题和解析