题解 | #实现四舍五入#
实现四舍五入
http://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
#include <iostream>
using namespace std;
int main() {
double d;
cin >> d;
// write your code here......
int ans=0;
if(d>0){
ans=(int)(d+0.5);
}else if(d<0){
ans=(int)(d-0.5);
}else{
ans=(int)d;
}
cout<<ans<<endl;
return 0;
}