/**
  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; 

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2022-01-07
  • 2022-01-07
  • 2021-09-18
  • 2021-11-27
  • 2021-06-04
  • 2021-11-11
猜你喜欢
  • 2022-02-14
  • 2021-05-19
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2021-06-22
相关资源
相似解决方案