题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <iostream>
using namespace std;
int main() {
string str;
getline(cin, str);
size_t res = 0;
size_t pos = str.find('.');
str = str.substr(0, pos);
if(str[pos+1] >= '5'){
res = stoi(str) + 1;
}else{
res = stoi(str);
}
cout << res << endl;
return 0;
}
// 64 位输出请用 printf("%lld")
查看5道真题和解析