fn main() {
println!("二つの数字を入力してください。");
let mut x = String::new();
let mut y = String::new();
std::io::stdin().read_line(&mut x).expect("Failed to read line");
x = x.trim_end().to_owned();
let x: i32 = x.parse::<i32>().unwrap();
std::io::stdin().read_line(&mut y).expect("Failed to read line");
y = y.trim_end().to_owned();
let y: i32 = y.parse::<i32>().unwrap();
println!("{} + {} = {}", x, y, x+y);
println!("{} - {} = {}", x, y, x-y);
println!("{} * {} = {}", x, y, x*y);
println!("{} / {} = {}", x, y, x/y);
}
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/basic`
二つの数字を入力してください。
24
6
24 + 6 = 30
24 – 6 = 18
24 * 6 = 144
24 / 6 = 4