Description
Enter a single-precision floating-point number, rounded toward zero to an integer.
Explanation: Rounding to zero means that positive numbers are rounded down and negative numbers are rounded up.
Hint: You can use casts to achieve this.
Input
A single-precision floating-point number.
Output
An integer, that is, the result of rounding toward zero to an integer.
Input sample
2.3
Output sample
2
Answer
1 | #include<iostream> using namespace std; int main() { float a; cin>>a; cout<<int(a)<<endl; return 0; } |
Result
Used memory: 200kB
Run time: 10ms
Language:G++
Submit time:2019-03-24 09:48:35
Problem link
http://noi.openjudge.cn/ch0102/06/
OpenJudge 06:Floating-point number rounding to zero
Comments