Skip to content
Snippets Groups Projects
Commit 35f63bf3 authored by Radim Vavřík's avatar Radim Vavřík
Browse files

Added cmd line arguments

parent c16318d2
Branches
Tags
No related merge requests found
......@@ -2,9 +2,10 @@
# include <iostream>
# include <iomanip>
# include <ctime>
#include <stdio.h>
# include "fire.h"
int main ( )
int main (int argc, char* argv[])
//****************************************************************************80
//
......@@ -18,15 +19,38 @@ int main ( )
//
{
int **forest;
int forest_size = 20;
int forest_size;
int i_ignite;
int j_ignite;
int offset;
double percent_burned = 0.0;
double prob_spread = 0.5;
int seed;
double u;
if (argc<3 || argc>3)
{
printf("Usage: fire forest_size seed\n");
printf(" forest_size number of trees in x-direction and y-direction\n");
printf(" seed for random fire ignition\n");
exit(1);
}
// read forest_size
forest_size = atoi(argv[1]);
if (forest_size < 1)
{
fprintf(stderr, "forest_size must be positive integer\n");
exit(-1);
}
// read seed
seed = atoi(argv[2]);
if (seed < 1)
{
fprintf(stderr, "seed must be positive integer\n");
exit(-1);
}
timestamp ( );
std::cout << "\n";
std::cout << "FIRE_SERIAL\n";
......@@ -36,8 +60,6 @@ int main ( )
//
// Initialize the random number generator.
//
offset = 0;
seed = seed_by_time ( offset );
std::cout << " The random number generator is seeded by " << seed << ".\n";
srand ( seed );
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment