Board logo

標題: 亂數 - 固定亂數 [打印本頁]

作者: tonyh    時間: 2014-3-8 16:41     標題: 亂數 - 固定亂數

本帖最後由 tonyh 於 2014-3-8 16:43 編輯

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

作者: 施伯叡    時間: 2014-3-8 16:41

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     for(int i=1; i<=20; i++)
  7.        cout<<rand()<<endl;
  8.     system("pause");     
  9.     return 0;
  10. }
複製代碼

作者: 張峻瑋    時間: 2014-3-8 16:41

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     for(int i=1;i<=20;i++)
  7.         cout<<rand()<<endl;                              
  8.     system("pause");
  9.     return 0;
  10. }
複製代碼

作者: 張郁庭    時間: 2014-3-8 16:43

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     for(int i=1; i<=20; i++)
  7.         cout<<rand()<<endl;
  8.     system("pause");
  9.     return 0;
  10. }
複製代碼

作者: 張郁偵    時間: 2014-3-8 16:43

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {         
  6.    
  7.     for(int i=1; i<=20; i++)
  8.          cout<<rand()<<endl;

  9.     system("pause");
  10.     return 0;   
  11. }
複製代碼

作者: 劉得旗    時間: 2014-3-8 16:43

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     for(int i=1; i<=20; i++)
  7.         cout<<rand()<<endl;   
  8.     system("pause");         
  9.     return 0;
  10. }
複製代碼

作者: 周雍程    時間: 2014-3-8 16:44

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     for(int i=1; i<=20; i++)
  7.           cout<<rand()<<endl;
  8.     system("pause");        
  9.     return 0;
  10. }
複製代碼

作者: 張彥承    時間: 2014-3-8 16:45

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   for(int i=1;i<=20;i++)
  7.   cout<<rand()<<endl;     
  8. system("pause");
  9. return 0;      
  10. }
複製代碼





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