2017-12-22 03:27:49 +00:00
|
|
|
extern crate rand;
|
|
|
|
|
2017-12-22 03:25:39 +00:00
|
|
|
use std::io;
|
2017-12-22 03:27:49 +00:00
|
|
|
use rand::Rng;
|
2017-12-22 03:25:39 +00:00
|
|
|
|
2016-08-31 02:49:38 +00:00
|
|
|
fn main() {
|
2017-12-22 03:25:39 +00:00
|
|
|
println!("Guess the number!");
|
|
|
|
|
2017-12-22 03:27:49 +00:00
|
|
|
let secret_number = rand::thread_rng().gen_range(1, 101);
|
|
|
|
|
|
|
|
println!("The secret number is: {}", secret_number);
|
|
|
|
|
2017-12-22 03:25:39 +00:00
|
|
|
println!("Please input your guess.");
|
|
|
|
|
|
|
|
let mut guess = String::new();
|
|
|
|
|
|
|
|
io::stdin().read_line(&mut guess)
|
|
|
|
.expect("Failed to read line");
|
|
|
|
|
|
|
|
println!("You guessed: {}", guess);
|
2016-08-31 02:49:38 +00:00
|
|
|
}
|