C++产生随机数

    xiaoxiao2022-06-25  200

    rand()   //产生随机数srand()  //获得随机数种子

    一般用法:

    #include <time.h> #include <stdlib.h> #include <iostream> using namespace std; int main(int argc, const char * argv[]) { srand((unsigned int) time(NULL)); for (int i = 0; i < 10; ++i) { cout<<rand() % 100 <<endl; } return 0; }

     

     

     

     

     

     

     

    参考:

    https://www.cnblogs.com/VVingerfly/p/5990714.html

     


    最新回复(0)