### 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 ?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344`` `````` 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.