Lottery example
Below is a sample for emulating a lottery. To compile GenerateDraws.C issue:
g++ -o GenerateDraws -0 3 GenerateDraws.C
GenerateDraws.C
#include <cstdlib> #include <unistd.h> #include <list> #include <algorithm> #include <fstream> int GetARandomNumberBetween1And60() { returnrandom()/(RAND_MAX/60)+1; }; void initrandom(unsigned seed){ #define RANDSIZE 256 static char randstate[RANDSIZE]; initstate(seed, randstate, RANDSIZE); } main(int argc,char ** argv) { initrandom(getpid()); // seeding for a new sequence of pseudo-random integers // let generate 8 number between 1 and 60 list<long int> Series; long int n; long long DrawNumber,InitialDrawNumber; ofstream OutputFileMonitor; OutputFileMonitor.open("Monitor"); DrawNumber=atoll(argv[1]); ...
Get Enabling Applications for Grid Computing with Globus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.