题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <iostream> #include<sstream> using namespace std; int main() { string x; cin>>x; stringstream geek(x); double y; geek>>y; int ans=(int)y; int a; for(int i=0;i<x.length();i++){ if(x[i]=='.'){ a=x[i+1]-'0'; break; } } if(a>=5){ ans++; } cout<<ans; return 0; } // 64 位输出请用 printf("%lld")