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

TOP

返回列表