题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
// HJ7 取近似值.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
void Data(double& n);
};
void Solution::Data(double& n)
{
int b;
b = (int)n;
double c = n - b;
if (c >= 0.5)
cout << b + 1 << endl;
else
cout << b << endl;
}
int main()
{
Solution a;
double n;
while (cin >> n)
{
a.Data(n);
}
return 0;
}
顺丰集团工作强度 434人发布