Skip to content

Instantly share code, notes, and snippets.

@goFrendiAsgard
Created October 12, 2018 02:41
Show Gist options
  • Save goFrendiAsgard/9bd4555d5dff852612ebccb09ba51131 to your computer and use it in GitHub Desktop.
Save goFrendiAsgard/9bd4555d5dff852612ebccb09ba51131 to your computer and use it in GitHub Desktop.
First experience with rust
// filename: coba.rs
// compile: rustc coba.rs
// run: ./coba
// compile and run: rustc coba.rs && ./coba
use std::io;
fn main() {
let stdin = io::stdin();
let mut my_str = String::new();
stdin.read_line(&mut my_str);
let my_int_1 = my_str.trim().parse::<i32>().unwrap();
my_str = String::new();
stdin.read_line(&mut my_str);
let my_int_2 = my_str.trim().parse::<i32>().unwrap();
let my_int_3 = my_int_1 + my_int_2;
println!("{} + {} = {}", my_int_1, my_int_2, my_int_3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment