#include <ctime>
#include <iostream>
usingnamespace std;
int main ()
{
constint NumberOfTests = 100; //How much numbers we will generate
constint MaximumSize = 1000; //maximum value of random value
int Biggest = 0; //var to save maximum value
int Number; //var to save actual number
srand(time(0)); //initializing random number generator
for (int a = 0; a < NumberOfTests; ++a) //main cycle
if ( (Number = rand()%MaximumSize) > Biggest) //test & generating random value
Biggest = Number;
cout << "Biggest number was: " << Biggest << endl;
system ("PAUSE");
return 0;
}
it is generating random values, and then shows the highest one
Since you have it based on the time clock hand for your random number generator, and loops are often able to process quicker than a second... it will come up with the same number for each loop within the same second.
Try putting a user pause in the middle of your loop. After the Biggest number have it pause. This will give enough time for the second to switch and you'll have a more likely random number.
... And it executes in less than a second, and all the numbers are different from one another. That seems kind of contrary to what you said.
I suppose if srand(time(0)) were called between each rand() function, then all the rand()s would return the same value if they were within the same second. But that's not the case here- srand() is called only once.