Add commandline parameters.

This commit is contained in:
2022-07-02 10:30:00 +02:00
parent 9e66334c27
commit 4f402b109d
3 changed files with 226 additions and 3 deletions

View File

@ -24,9 +24,21 @@
extern crate rand;
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt(about = "An implementation of the Skyum's Protocol.")]
struct Opt
{
#[structopt(short, long, default_value="100", help = "The number of inmates in the problem")]
size:u32,
}
fn main() {
let opts = Opt::from_args();
// set number of prisoners in experiment
let size = 100;
let size = opts.size;
// initialize the boxes with capacity for `size` number of boxes
let mut boxes:Vec<u32> = Vec::with_capacity(size as usize);
@ -82,10 +94,10 @@ fn main() {
// print result
if all_found
{
println!("All prisoners found their numbers!");
println!("success");
}
else
{
println!("Some prisoners didn't find their numbers!");
println!("failure");
}
}