题解 | #实现四舍五入#
实现四舍五入
https://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
#include <iostream> using namespace std; int main() { float a=0.5; float b; int c=0; scanf("%f",&b); if(b>=0) { c=b; if(b>=c+a) { c++; } printf("%d",c); return 0; } else if(b<0) { a=-0.5; c=b; if(b<=c+a) { c--; } printf("%d",c); return 0; } } // 64 位输出请用 printf("%lld")