- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- string n[7]={"子耕", "思惟", "璽安", "侑成", "奇奇", "阿尼", "挺桂"};
- int x[3];
- srand(time(NULL));
- for(int i=0; i<3; i++)
- {
- x[i]=rand()%7;
- for(int j=0; j<i; j++)
- {
- if(x[i]==x[j])
- {
- i--;
- break;
- }
- }
- }
- cout<<"掃廁所三位同學: ";
- for(int i=0; i<3; i++)
- cout<<n[x[i]]<<" ";
- cout<<endl;
- system("pause");
- goto re;
- return 0;
-
-
- }
複製代碼 |