返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         //產生20組數值,每組皆包含4個介於0~9之隨機亂數,每隔 0.5秒 產生一組。_sleep(N)可讓程式暫停執行N毫秒
  8.        

  9.         srand(time(NULL));
  10.     for(int i=1; i<=20; i++){
  11.             for(int j=1; j<=4; j++){
  12.             cout<<rand()%10<<"        ";
  13.            
  14.                 }
  15.                 cout<<endl;
  16.                 _sleep(500);
  17.         }
  18.         
  19.     system("pause");   
  20.     return 0;
  21. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         //產生20組數值,每組皆包含4個介於0~9之隨機亂數,每隔 0.5秒 產生一組。_sleep(N)可讓程式暫停執行N毫秒
  8.        

  9.         srand(time(NULL));
  10.         int n[4];
  11.     for(int i=1; i<=20; i++){
  12.             for(int j=1; j<=4; j++){
  13.             n[j-1]=rand()%10;
  14.            
  15.                 }
  16.                 for(int k=0;k<=3;k++){
  17.                         cout<<n[k]<<"        ";
  18.                 }
  19.                 cout<<endl;
  20.                 _sleep(500);
  21.         }
  22.         
  23.     system("pause");   
  24.     return 0;
  25. }
複製代碼

TOP

返回列表