Hello,

I'm new with coding c/c++ and uniform random generator. I had to code the wichmann-hill.

I need to generate about 30,000 random numbers, but i dont know how to.

Here is my cpp code so far.

Can anyone please help?

I'm new with coding c/c++ and uniform random generator. I had to code the wichmann-hill.

I need to generate about 30,000 random numbers, but i dont know how to.

Here is my cpp code so far.

Can anyone please help?

Code:

#include <stdio.h> #include <cstdlib.h> #include <math.h> #include <fstream.h> #include <time.h> int main (void) { int x1, y1, z1, i; float random, temp, r; srand( time(NULL)); x1 = (1+ rand()) % 200; y1 = (1000 + rand()) % 10000; z1 = (300 + rand()) % 3000; x1 =171 * (x1 % 177) - 2 * (x1 / 177); if (x1 < 0) { x1 = x1 + 30269; } y1 =172 * (y1 % 176) - 35 * (y1 / 176); if (y1 < 0) { y1 = y1 + 30307; } z1 =170 * (z1 % 178) - 63 * (z1 / 178); if (z1 < 0) { z1 = z1 + 30323; } temp = (float) x1/30269.0 + (float) y1/30307.0 + (float) z1/30323.0; random = temp - floor(temp); ofstream outputFile("dolly.txt", ios::out); //outputFile << random << endl; outputFile.close(); return 0; }

*Last edited by shabbir; 12Aug2009 at 08:47.. Reason: Code blocks*