update
This commit is contained in:
@@ -83,6 +83,22 @@ fn main() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,40 @@
|
||||
/* --------------------------------------------- 100 -------------------------------------------- */
|
||||
use rand::prelude;
|
||||
use std::prelude;
|
||||
|
||||
use rand::{Rng, thread_rng};
|
||||
use std::io::{self, stdin};
|
||||
|
||||
fn main () {
|
||||
|
||||
let mut myrng = thread_rng();
|
||||
let secret_number = myrng.gen_range(1..100);
|
||||
|
||||
loop {
|
||||
let mut user_guess = String::new();
|
||||
let std_in = stdin();
|
||||
match std_in.read_line(&mut user_guess) {
|
||||
Ok(_) => {
|
||||
// The underscore _ means we don't care about the byte count
|
||||
// We just care that it succeeded.
|
||||
println!("You guessed: {}", user_guess);
|
||||
},
|
||||
Err(error) => {
|
||||
// Here we handle the error manually
|
||||
println!("Problem reading input: {}", error);
|
||||
}
|
||||
}
|
||||
println!("please input you guess number");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user