select a number < 8 return a randle number that <= 7

/**

  select a number < 8 



  return a randle number that <= 7

*/

int selrand()

{

        int iSecret, iGuess;

        bool iselect = true;

        static vector< int > selected;

        static vector< int >::iterator itsel;



        /* initialize random seed: */

        srand( time( NULL ) );



        /* generate secret number: */

        do

        {

               iSecret = rand() % 8;

                                        

                itsel = find( selected.begin(), selected.end(), iSecret );

                if ( itsel == selected.end() )

                {

                        selected.push_back( iSecret );

                        iselect = false;

                }               

                

        } while ( iselect );

        

        return iSecret; 

你可能感兴趣的:(select)