In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the method of Qt generating random numbers". In daily operation, I believe many people have doubts about what is the method of Qt generating random numbers. The editor consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "what is the method of Qt generating random numbers"! Next, please follow the small series to learn together!
1. generating a random number
Random number generation mainly uses the functions qsrand and qrand, these two functions in #include, qsrand is used to set a seed, the seed is qrand generate random number starting value. For example, qsrand(10), set 10 as the seed, then qrand generates random numbers between [10, 32767]. If qsrand () has not been called before qrand (), qrand() automatically calls qsrand(1), i.e., the system defaults to 1 as the starting value for random numbers. Random numbers generated using the same seed.
The following code generates 10 random numbers between [0,9].
void generateRandomNumber(){ qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); for(int i=0; i
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.