返回列表 發帖

亂數 - 產生介於指定範圍內的隨機亂數 (二)

本帖最後由 陳品肇 於 2018-11-10 16:33 編輯

產生15組 範圍介於725~1088的隨機亂數
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     srand(time(NULL));
  7.     for(int i=1; i<=15; i++)
  8.         cout<<rand()%364+725<<endl;  //725指的最小值   364 = 最大值-最小值+1
  9.     system("pause");         
  10.     return 0;
  11. }
複製代碼

返回列表