题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <bits/stdc++.h> using namespace std; int main() { string s; while(getline(cin,s)) { //find '.' for(int i=0;i<s.length();i++) { if(s[i]=='.') { if(s[i+1]>='5') { s[i-1]++; } cout<<s.substr(0,i)<<endl; break; } } } } // 64 位输出请用 printf("%lld")