-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrust.rs
39 lines (36 loc) · 888 Bytes
/
rust.rs
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
39
use std::io;
macro_rules! r {
($x:expr, $t:ident) => {
$x.trim().parse::<$t>().unwrap()
};
}
fn main() {
let mut input_line = String::new();
io::stdin().read_line(&mut input_line).unwrap();
let i = input_line.split(" ").collect::<Vec<_>>();
let l = r!(i[0], i32);
let m = r!(i[1], i32);
let mut x = r!(i[2], i32);
let mut y = r!(i[3], i32);
loop {
let mut input_line = String::new();
io::stdin().read_line(&mut input_line).unwrap();
let mut my_move = "".to_string();
if y > m {
my_move += "N";
y += -1;
} else if y < m {
my_move += "S";
y += 1;
}
if x > l {
my_move += "W";
x += -1;
}
if x < l {
my_move += "E";
x += 1;
}
println!("{my_move}");
}
}