新建Empty qmake project,命名为UseRand
UseRand.pro
SOURCES += main.cpp QT += core
main.cpp
#include <QTime> #include <QTextStream> const int RAND_POS = 29; const int DOT_SIZE = 10; int main() { QTextStream out(stdout); QTime time = QTime::currentTime(); qsrand((uint) time.msec()); int r = qrand() % RAND_POS; int x = (r * DOT_SIZE); out << RAND_POS << endl; out << x << endl; return 0; }
时间: 2024-12-12 13:15:47