- #include<iostream>
- #include<ctime>
- using namespace std;
- int main()
- {
- re:
- int c[3];
- srand(time(NULL));
- string a[5]= {"子耕", "思惟", "璽安", "侑成", "挺桂"};
- cout<<"要掃廁所的同學是:";
- for(int b=0; b<3; b++)
- {
- c[b]=rand()%5;
- for(int d=0; d<b; d++)
- {
- if(c[b]==c[d])
- {
- b--;
- break;
- }
- }
- }
- cout<<a[c[0]]<<","<<a[c[1]]<<","<<a[c[2]]<<endl;
- system("pause");
- system("cls");
- goto re;
- return 0;
- }
複製代碼 |