返回列表 發帖

亂數 - 種子亂數

本帖最後由 tonyh 於 2015-4-18 11:11 編輯

先設定亂數種子, 再利用 rand() 函式產生20組種子亂數.
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     srand(5);    //設定亂數種子
  7.     for(int i=1; i<=20; i++)
  8.         cout<<rand()<<endl;    //使用rand()函式產生固定亂數
  9.     system("pause");
  10.     return 0;
  11. }
複製代碼

返回列表