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

TOP

返回列表