The sum command for MacOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 line
291B

  1. use std::io::{self, BufRead};
  2. fn main() {
  3. let stdin = io::stdin();
  4. let sum: u32 = stdin
  5. .lock()
  6. .lines()
  7. .map(|line| -> u32 {
  8. let num: u32 = line.unwrap().parse().unwrap_or(0);
  9. num
  10. }).sum();
  11. println!("{}", sum);
  12. }