返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<iostream>
  4. #include<ctime>
  5. using namespace std;
  6. int main()
  7. {
  8.     srand(time(NULL));
  9.     for(int i=0; i<20; i++)
  10.     {
  11.          int n[4];
  12.          for(int j=0; j<4; j++)
  13.          {
  14.               n[j]=rand()%10;  
  15.               for(int k=0; k<j; k++)
  16.               {
  17.                    if(n[k]==n[j])
  18.                    {
  19.                        j--;
  20.                        break;              
  21.                    }
  22.               }
  23.          }  
  24.          for(int j=0; j<4; j++)
  25.          {
  26.               cout<<n[j]<<" ";
  27.          }
  28.          cout<<endl;
  29.          _sleep(500);
  30.     }
  31.     system("pause");
  32.     return 0;   
  33. }
複製代碼

TOP

返回列表