Questions:
1- why my cout = array + 1? In other words, why im getting one random number more than the array allocation.
2- how i can get a unique set of random number allocate in the array?
3- how i compare the numbers allocate in the array?
some examples with comments are very welcome.
void Gen::UserMax()
{
cout << "Enter the maximum number of random numbers to generate: ";
cin >> userMax;
}
void Gen::DigitMax()
{
cout << "Enter the maximum number of digits each random numbers contains: ";
cin >> digitMax;
}
void Gen::generatorRandoms()
{
srand(time(0));
int modNumber = 0;
int randomNumber = 0;
int j = 0;
if (digitMax == 2)
{
modNumber = 100;
}
for ( int i = 0; i< userMax; i ++)
{
randoms[j]=rand() % modNumber;
if ( randoms[j] <=10)// Control minimum number of digits
{
i--;
}
if ( randoms[j] >=10)// Control maximum number of digits
{
cout<< randoms[j]<< "\t";
}
}
}