00001 /*------------------------------------ Includes ---------------------------------------------*/ 00002 #include "gen_rnd.h" 00003 00004 #include <stdlib.h> 00005 #include <time.h> 00006 #include <assert.h> 00007 00008 00009 00010 00011 /****************************************************************************************************/ 00012 // class cRnd_Number_Generator 00013 /****************************************************************************************************/ 00014 cRnd_Number_Generator::cRnd_Number_Generator() 00015 { 00016 00017 srand(time(NULL)); 00018 } 00019 00020 /*--------------------------------------------------------------------------------------------------*/ 00021 int cRnd_Number_Generator::Get_Int(int n_max) 00022 { 00023 assert( n_max > 0); 00024 return rand()%(n_max+1); 00025 } 00026 00027 /*--------------------------------------------------------------------------------------------------*/ 00028 int cRnd_Number_Generator::Get_Int(int n_min , int n_max) 00029 { 00030 assert( n_min < n_max); 00031 assert( n_min >= 0); 00032 return n_min+rand()%(n_max-n_min+1); 00033 }