返回列表 發帖
  1. #include<cstdlib>
  2. #include<iostream>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     srand(time(NULL));
  8.     int n[10];        
  9.     for(int j=0; j<10; j++)   
  10.     {
  11.         n[j]=rand()%38+1;  

  12.         for(int k=0; k<j; k++)
  13.         {
  14.             if(n[j]==n[k])
  15.             {
  16.                
  17.                j--;
  18.                break;              
  19.             }
  20.         }
  21.     }  
  22.     cout<<"我拿到的球為: ";
  23.     for(int j=0; j<10; j++)
  24.     {
  25.         cout<<n[j]<<" ";  
  26.         _sleep(500);
  27.     }  
  28.     cout<<endl<<endl;  
  29.     system("pause");
  30.     return 0;   
  31. }
複製代碼

TOP

返回列表