标签:二次 pre inf names style span info center strong
srand()与rand()生成随机数
经过测试,当srand的值确定时,其对应的rand值也是确定的。
#include <iostream> using namespace std; int main() { for (int i = 0; i <= 10; i++) { srand(i); cout << "当seed = " << i << "时,其结果为:" << rand() << endl; } cout << endl << endl << "------第二次验证---------" << endl << endl; for (int i = 0; i <= 10; i++) { srand(i); cout << "当seed = " << i << "时,其结果为:" << rand() << endl; } }
标签:二次 pre inf names style span info center strong
原文地址:https://www.cnblogs.com/onetrainee/p/12177659.html