题解 | #取近似值#
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
解题思路:round()
use std::io::{self, *};
use std::str::FromStr;
fn main() {
let stdin = io::stdin();
unsafe {
for line in stdin.lock().lines() {
let ll = line.unwrap();
println!("{}",(f64::from_str(ll.as_str()).unwrap()).round());
}
}
}
用 Rust 刷华为机试HJ 文章被收录于专栏
用 Rust 刷 HJ100 题,只需要懂基础 Rust 语法就能看懂
查看3道真题和解析