Add commandline parameters.
This commit is contained in:
18
src/main.rs
18
src/main.rs
@ -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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user