B2016 浮点数向零舍入

B2016 浮点数向零舍入

?这题需要用浮点数?
by ivyjiao @ 2022-10-14 11:13:43


@[ivyjiao](/user/578029) 这题**不用**浮点数? _“输入一个**单精度浮点数**,将其向零舍入到整数。说明:向零舍入的含义是,正数向下舍入,负数向上舍入。”_ 是不是**看错题了**???
by Tjaweiof @ 2023-03-10 13:28:10


@[huzhage](/user/827877) **确实**,单精度有 6 位小数,双精度有 15 位小数,本题**第4测试点15位**。。。
by Tjaweiof @ 2023-03-10 13:30:44


@[Chenzhehao](/user/550933) ``` #include<iostream> using namespace std; int main(){ long long x; cin>>x; cout<<x; } ```
by PDOI @ 2023-03-11 14:24:05


@[Chenzhehao](/user/550933) 哈哈哈,int 自动舍入不知道吗
by ACPC @ 2023-03-11 14:32:00


@[A_Passing_Creeper](/user/540363) 艹6,我用的字符串
by Loser_Syx @ 2023-03-11 14:33:10


@[huzhage](/user/827877) 本SB字符串做法 ```cpp #include <bits/stdc++.h> using namespace std; int main(){ string s;cin >> s; for(int i = 0; i < s.size(); i++){ if(s[i] == '.') return 0; else cout << s[i]; } } ```
by Loser_Syx @ 2023-03-11 14:33:40


@[PDOI](/user/777756) @[A_Passing_Creeper](/user/540363) 好吧,这种方法我还真没想到。。。 _~~**我弱啊**~~_
by Tjaweiof @ 2023-03-12 09:28:33


|