题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
use std::io::{self, *};
fn main() {
let stdin = io::stdin();
unsafe {
for line in stdin.lock().lines() {
let ll = line.unwrap();
let numbers: Vec<&str> = ll.split(".").collect();
let a = numbers[0].trim().parse::<i32>().unwrap_or(0);
// println!("{}", a);
let mut b = numbers[1].trim().parse::<i32>().unwrap_or(0);
while b > 10 {
b = b / 10;
}
// println!("{}", b);
if b >= 5 {
println!("{}", a + 1);
} else {
println!("{}", a);
}
}
}
}
