Skip to content

Commit 4d1433b

Browse files
committed
feat: 添加实现四舍五入的C++算法
1 parent 9c6ee26 commit 4d1433b

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* @Author: tkzzzzzz6
3+
* @Date: 2026-04-28 09:41:21
4+
* @LastEditors: tkzzzzzz6
5+
* @LastEditTime: 2026-04-28 09:41:40
6+
*/
7+
/**
8+
* @nc app=nowcoder id=020a0cf673174d5795d97ae79cff59a0 topic=225 question=2177130 lang=C++
9+
* 2026-04-28 09:41:21
10+
* https://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0?tpId=225&tqId=2177130
11+
* [CPP2] 实现四舍五入
12+
*/
13+
14+
/** @nc code=start */
15+
16+
#include<bits/stdc++.h>
17+
#define il inline
18+
#define endl '\n'
19+
using namespace std;
20+
21+
#define pb push_back
22+
#define fastio \
23+
ios::sync_with_stdio(false); \
24+
cin.tie(0);
25+
26+
typedef long long ll;
27+
typedef unsigned long long ull;
28+
29+
const ll N = 5e5+5, mod = 1e9+7, inf = 2e18;
30+
const double eps = 1e-9;
31+
const double PI = 3.1415926;
32+
33+
il void solve(){
34+
double t;
35+
cin >> t;
36+
cout << round(t) << endl;
37+
// cout << (long long)(t + 0.5); //只适用非负数
38+
}
39+
40+
int main()
41+
{
42+
fastio;
43+
44+
int t = 1;
45+
// cin >> t;
46+
while(t--)
47+
{
48+
solve();
49+
}
50+
51+
return 0;
52+
}
53+
54+
/** @nc code=end */

0 commit comments

Comments
 (0)