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

TOP

返回列表