- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int a, b, c, r;
- string name[]={"子耕","思惟","璽安","侑成","挺桂"};
- for(int i=1; i<=1; i++){
- int a=-1, b=-1, c=-1;
- cout<<"掃廁所的人有: ";
- for(int j=1; j<=3; j++){
- r=rand()%4;
- if(a!=r && b!=r && c!=r){
- cout<<name[r]<<" ";
- c=b;
- b=a;
- a=r;
- }
- else{
- j--;
- }
- }
- cout<<endl;
- _sleep(500);
- }
- system("pause");
- return 0;
- }
複製代碼 |