Skip to content
Snippets Groups Projects
Commit 155b3b2c authored by David Horvát's avatar David Horvát
Browse files

sample program

parent 4d424055
No related branches found
No related tags found
No related merge requests found
[package]
name = "some-program"
version = "2.5.4"
edition = "2021"
[dependencies]
rand = "0.9.0"
\ No newline at end of file
use rand::Rng;
use rand::seq::SliceRandom;
fn generate_star_pattern(width: usize, height: usize) {
let mut rng = rand::thread_rng();
for _ in 0..height {
for _ in 0..width {
if rng.gen_bool(0.2) { // 20% chance of printing a star
print!("*");
} else {
print!(" ");
}
}
println!(); // Move to the next line after each row
}
}
fn main() {
let width = 18;
let height = 8;
println!("+--(-----------)--+");
generate_star_pattern(width, height);
println!("+--(-----------)--+");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment