Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int myRand(int min, int max){
- int result = 0 , low = 0 ,hig = 0;
- static int oneTime = 0; // Srand patch
- if ( min < max) {
- low = min;
- hig = max + 1; // include the max result in the output
- } else {
- low = max + 1; // include the max result in the output
- hig = min;
- }
- if (oneTime == 0) { // you only run srand 1 time.
- srand(time(NULL));
- oneTime++;
- }
- result = (rand() % hig - low)+ low;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement