update
This commit is contained in:
14
guessing_game/Manifest.toml
Normal file
14
guessing_game/Manifest.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
# This file is machine-generated - editing it directly is not advised
|
||||
|
||||
julia_version = "1.12.5"
|
||||
manifest_format = "2.0"
|
||||
project_hash = "9e64cf17f9522d20edabe6f2b4ec85252943fcae"
|
||||
|
||||
[[deps.Random]]
|
||||
deps = ["SHA"]
|
||||
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
version = "1.11.0"
|
||||
|
||||
[[deps.SHA]]
|
||||
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
||||
version = "0.7.0"
|
||||
2
guessing_game/Project.toml
Normal file
2
guessing_game/Project.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[deps]
|
||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
3
guessing_game/main.jl
Normal file
3
guessing_game/main.jl
Normal file
@@ -0,0 +1,3 @@
|
||||
using Base
|
||||
|
||||
guess_number = Base.rand([1:1:100...])
|
||||
@@ -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