题解 | #牛牛学说话之-浮点数#
牛牛学说话之-浮点数
https://www.nowcoder.com/practice/7c3bf58fac1a4eb69fa32c2d2c379bac
use std::io::stdin;
fn main() {
let mut input = String::new();
stdin().read_line(&mut input).ok().expect("Failed to read line");
let f: f32 = match input.trim().parse() {
Ok(f) => f,
Err(_) => {
println!("请输入\"float\"类型的内容,请勿输入无关符号!");
return;
}
};
println!("{:.3}",f);
}