- #include<cstdlib>
- #include<iostream>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- for(int a=0; a<20; a++)
- int b[4];
- for(int x=0; x<4; x++)
- {
- b[x]=rand()%10;
- for(int y=0; y<x; y++)
- {
- if(b[x]==b[y])
- x--;
- break;
- }
- }
- for(int x=0; x<4; x++)
- cout<<b[x]<<" ";
- cout<<endl;
- _sleep(500);
- system("pause");
- return 0;
- }
複製代碼 |