main.rs hinzugefügt

Batman! (this commit has no parents)
This commit is contained in:
robin 2024-05-09 12:55:35 +02:00
commit c74e306403

26
main.rs Normal file
View file

@ -0,0 +1,26 @@
use rand::Rng;
fn main() {
let mut number:i128 = 0;
loop {
let rng:i128 = rand::thread_rng().gen_range(1..=1000000000000000000000000);
println!("Do you want to add {} to the number", rng);
println!("Your number is {}(y/n)", number);
let mut input: String = String::new();
std::io::stdin().read_line(&mut input).expect("Failed to read line");
let input: String = input.trim().parse().unwrap();
let yes:String = String::from("y");
let no = String::from("no");
if input == yes {
let number = number+=rng;
}
else if input == no {
}
else {
println!("Invalid input");
}
}
}