rand() not generating random numbers after modulo operation

后端 未结 8 2044
一向
一向 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 04:44

    Random number generator must be initialized with random seed. See srand() function. Often it initialized with time: srand(time(NULL)).

提交回复
热议问题