Board logo

標題: 亂數 - 種子亂數 [打印本頁]

作者: 陳育霖    時間: 2023-7-25 23:02     標題: 亂數 - 種子亂數

本帖最後由 陳育霖 於 2024-1-17 21:21 編輯

先設定亂數種子,再利用 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;
  9.     system("pause");   
  10.     return 0;
  11. }
複製代碼

作者: 陳品諺    時間: 2023-8-1 16:43

此帖僅作者可見
作者: 盧承新    時間: 2024-1-17 21:21

此帖僅作者可見
作者: 陳頤寬    時間: 2024-1-20 14:35

此帖僅作者可見
作者: 王子夫    時間: 2024-7-27 14:51

此帖僅作者可見
作者: 李昱辰    時間: 2024-8-5 20:03

此帖僅作者可見




歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2