rand() not generating random numbers after modulo operation

后端 未结 8 2050
一向
一向 2020-12-07 04:43

I\'m taking a C refresher and took on a board game as an exercise. The board game is \"Game of the Generals\" and is pretty much like chess as it uses pieces with ranks on a

8条回答
  •  广开言路
    2020-12-07 05:10

    Make sure to initialize / seed the random number generator:

    #include 
    
    srand(time(NULL));
    

提交回复
热议问题