use std::io; use std::str::FromStr; #[allow(dead_code)] fn read_line() -> T{ let mut s = String::new(); io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(dead_code)] fn read_delimiter(delimiter: &str) -> Vec{ let s = read_line::(); s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::>() } fn main() { let s = read_delimiter::(","); let mut num = 0; for i in s.iter(){ num += i; } println!("合計点:{}",num); let num: f64 = num as f64 / s.len() as f64; println!("平均点:{:.1}",num); }