1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::io;
use std::str::FromStr;
pub fn scann<T: FromStr>() -> T where <T as FromStr>::Err: std::fmt::Debug {
let mut number = String::new();
io::stdin().read_line(&mut number).expect("IO error");
number.trim().parse::<T>().expect("Input error")
}
pub fn scanvec<T: FromStr>() -> Vec<T> where <T as FromStr>::Err: std::fmt::Debug {
let mut vec = String::new();
io::stdin().read_line(&mut vec).expect("IO error");
let vec = vec
.split_whitespace()
.map(|x| x.parse::<T>().expect("Parse error"))
.collect::<Vec<T>>();
vec
}
pub fn scanln() -> String {
let mut string = String::new();
io::stdin().read_line(&mut string).expect("IO ERROR");
let trim: &[_] = &['\n', '\r'];
string.trim_end_matches(trim).to_owned()
}