16 Create a library complete with source file dicecpp 2 head

16] Create a library, complete with source file dice.cpp [2], header dice.h [2], makefile Makefile [2], and a main code main.cpp [2]. The library should contain functions: [2] void di::seed(), which seeds the random number generator. [2] int di::random(int a, int b), which obtains a random number in range [a, b]. [4] int di::dice(int A, int X, int B) which obtains a random number by rolling the dice AdX+B. See the following article on dice notation for precisely what this means. Note that you must generate random numbers for all X dice. https://en.wikipedia.org/wiki/Dice_notation MUST BE IN C++ AND MUST BE THE ACTUAL CODE

Solution

// gcc -std=c99 -o go go.c neuron.c -lm #include #include #include #include \"neuron.h\" int main(int argc, char *argv[]) { int ncells = 100; // # cells to process char fnum[4], fname[128]; // filename strings double celldirs[40], cellspks[40]; // data for each cell double PD[ncells], plate_out[9]; // store cell PDs // loop to process each cell int i; for (i=1; i<=ncells; i++) { // construct the numeric part of the filename if (i<10) sprintf(fnum, \"00%d\", i); else if (i<100) sprintf(fnum, \"0%d\", i); else sprintf(fnum, \"%d\", i); // read in a dirs data file sprintf(fname, \"data/cell_dirs_%s.txt\", fnum); readcell(fname, celldirs, 40, 0); // read in a spks data file sprintf(fname, \"data/cell_spks_%s.txt\", fnum); readcell(fname, cellspks, 40, 0); // compute PD PD[i-1] = compute_PD(celldirs, cellspks, 40); } // print vector of PDs to screen and write to a file show_double_vec(PD, ncells); write_double_vec(PD, ncells, \"PDs.txt\"); return 0; }
16] Create a library, complete with source file dice.cpp [2], header dice.h [2], makefile Makefile [2], and a main code main.cpp [2]. The library should contain

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site