rand() returns the same number each time the program is run

后端 未结 6 1690
自闭症患者
自闭症患者 2021-02-02 10:46

In this rather basic C++ code snippet involving random number generation:

include 
using namespace std;

int main() {
    cout << (rand() %         


        
6条回答
  •  别那么骄傲
    2021-02-02 11:27

    You need to "seed" the generator. Check out this short video, it will clear things up.

    https://www.thenewboston.com/videos.php?cat=16&video=17503

提交回复
热议问题