randoms number in specific range of number

I need some help, i'm trying to finish this code but I cant display correctly . I was ask to get from the user a range of digit for a random and a maximums of number that this random number will displayed. also this set of random number needs to be unique. So far the issue I have is displaying the random number between the desire range. I try a lot off thing but I never get the correct code. any suggestion ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

bool randonUnique( const int array[], int ranNumber, int value )
{
    for( int i = 0 ; i < ranNumber; ++i )
        if( array[i] == value ) return true ;
    return false ;
}
void GenRandoms::generateRandoms()
{
	int j=0;
	int modNumber = 10;
	int randomNumber = 0;
	long int getRandoms = 0;
	int setRandoms=0;
        
	if (digitMax == 2)
	{
		int m= 10;
		modNumber = 100;
		for ( int j = 0 ; j< userMax; j++)
	{	
	    do getRandoms =( rand() % modNumber);
		 while( randonUnique( randoms, j, getRandoms ) ) ;//get unique set of random			
		 randoms[j] = getRandoms;
		 cout << randoms[j] << "\t";
	}
	
	}
	else
	if (digitMax == 3)
	{
		modNumber = 1000;
		for ( int j = 0 ; j< userMax; j++)
	{	
	    do getRandoms =( rand() % modNumber);
        while( randonUnique( randoms, j, getRandoms ) ) ;
	 if(digitMax == 3 && getRandoms <= 100)
    {  
		getRandoms = getRandoms + 100;
	}
		
		randoms[j] = getRandoms ;
		cout << randoms[j] << "\t";
    }
Last edited on
Topic archived. No new replies allowed.