Board logo

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

作者: 周政輝    時間: 2018-3-24 13:37     標題: 亂數 - 固定亂數

利用 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;
  8.     system("pause");   
  9.     return 0;
  10. }
複製代碼

作者: 林峻安    時間: 2018-3-24 14:06

  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. }
複製代碼

作者: 黃安立    時間: 2018-3-24 14:06

  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;
複製代碼

作者: 顏詢    時間: 2018-3-24 14:07

  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. }
複製代碼

作者: 戴嘉禾    時間: 2018-3-24 14:09

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

作者: 王駿愷    時間: 2018-3-24 14:10

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

作者: 吳秉翰    時間: 2018-3-24 14:12

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

作者: 鄭楀諺    時間: 2018-4-21 13:24

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





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