- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int a, b, c, r;
- for(int i=1; i<=20; i++){
- int a=-1, b=-1, c=-1;
- for(int j=1; j<=4; j++){
- r=rand()%10;
- if(a!=r && b!=r && c!=r){
- cout<<r<<" ";
- c=b;
- b=a;
- a=r;
- }
- else{
- j--;
- }
- }
- cout<<endl;
- _sleep(500);
- }
- system("pause");
- return 0;
- }
複製代碼 |