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

后端 未结 6 1765
自闭症患者
自闭症患者 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:30

    random functions like borland complier

    using namespace std;
    
    int sys_random(int min, int max) {
       return (rand() % (max - min+1) + min);
    }
    
    void sys_randomize() {
        srand(time(0));
    }
    

提交回复
热议问题