C++ 随机数字以及随机数字加字母生成

#include <time.h>
#include <sys/timeb.h>
void MainWindow::slot_clicked()
{
QString strRand;
int length = 32;
QString strTmp = "1234567890QWERTYUIOPASDFGHJKLZXCVBNM";
struct timeb timer;
ftime(&timer);
srand(timer.time * 1000 + timer.millitm);//毫秒种子

for(int i = 0; i < length; i++ )
{
int j = rand()%35;
strRand += strTmp.at(j);
}
qDebug() << strRand;

posted @ 2019-03-22 15:02  wjbooks  阅读(1730)  评论(0编辑  收藏  举报