返回列表 發帖
  1.     #include<iostream>
  2.     #include<cstdlib>
  3.     using namespace std;
  4.     int main()
  5.     {
  6.         re:
  7.         string n[7]={"子耕", "思惟", "璽安", "侑成", "奇奇", "阿尼", "挺桂"};
  8.         int x[3];
  9.         srand(time(NULL));
  10.         for(int i=0; i<3; i++)
  11.         {
  12.              x[i]=rand()%7;   
  13.              for(int j=0; j<i; j++)
  14.              {
  15.                   if(x[i]==x[j])
  16.                   {
  17.                       i--;
  18.                       break;              
  19.                   }
  20.              }  
  21.         }
  22.         cout<<"掃廁所三位同學: ";
  23.         for(int i=0; i<3; i++)
  24.             cout<<n[x[i]]<<" ";
  25.         cout<<endl;
  26.         system("pause");
  27.         goto re;
  28.         return 0;
  29.         
  30.         
  31.     }
複製代碼

TOP

返回列表