Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #![allow(unused)]
  2. // fn main() {
  3. // let k = String::from("0.01");
  4. // let amount = ((k.parse::<f64>().unwrap()) * 100.00).trunc() as i64;
  5. // println!("{}",amount);
  6. // }
  7.  
  8. use std::io;
  9.  
  10. fn main() {
  11. let mut input_line = String::from("1234567");
  12. io::stdin().read_line(&mut input_line).unwrap();
  13. // let n = parse_input!(input_line, i64);
  14.  
  15. let mut res = input_line.chars()
  16. .map(|c| c.to_digit(10).unwrap())
  17. .filter(|c| c%2==0)
  18. .fold(0,|acc,c| acc+=1);
  19.  
  20. // let mut res= 0;
  21. // for c in input_line.chars(){
  22. // let num = c.to_digit(10).unwrap();
  23.  
  24. // if(num%2==0){
  25. // eprintln!("{}",c);
  26. // res += num;
  27. // }
  28.  
  29. // }
  30.  
  31. // Write an action using println!("message...");
  32. // To debug: eprintln!("Debug message...");
  33.  
  34. println!("{}", res);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement