题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
#include <iostream>
using namespace std;
int main(){
float a; //5.5
cin >> a; //5.5
int c = int(a); //5
float temp = a - c; //0.5
if (temp >= 0.5) cout << c + 1; // 5 + 1
else cout << c;
}
查看7道真题和解析