返回列表 發帖
  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.    
  10.     for(int j=0; j<10; j++)     
  11.     {
  12.         n[j]=rand()%38+1;  
  13.         for(int k=0; k<j; k++)   
  14.         {
  15.             if(n[j]==n[k])   
  16.             {
  17.                
  18.                j--;
  19.                break;              
  20.             }
  21.         }
  22.     }  
  23.     cout<<"我拿到的球為: ";
  24.     for(int j=0; j<10; j++)
  25.     {
  26.         cout<<n[j]<<" ";   
  27.         _sleep(500);
  28.     }  
  29.     cout<<endl<<endl;  
  30.     system("pause");
  31.     return 0;   
  32. }
複製代碼

TOP

返回列表