Hello everybody,

I have some numbers, for example 16, 20, 23, 40, 43

I need to generate a random number of only this numbers i have.

How could i make this on QT or C++ ??

Can somebody help me?


For the moment i have this:
Qt Code:
  1. int max;
  2. QSqlQuery count("select count(words_id) from words_tbl");
  3. while(count.next())
  4. {
  5. max = count.value(0).toInt();
  6. }
  7.  
  8. //random
  9. int a = (1 + ( rand() % ( max - 1 + 1 ) ));
  10. QString b = QString::number(a);
To copy to clipboard, switch view to plain text mode