相关文章推荐
爱搭讪的芒果  ·  带你学MySQL系列 | ...·  1 年前    · 
沉稳的木瓜  ·  powershell ...·  2 年前    · 
2 time= QTime::currentTime(); 3 qsrand(time.msec()+time.second()* 1000 ); 4 int n = qrand() % 5 ; // 产生5以内的随机数

第二种方法

1 #include <ctime>
2 #include <QtGlobal>
1     qsrand(time(NULL));
2     int n = qrand() % 5;    //产生5以内的随机数