返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     int r[4];
  7.     srand(time(NULL));
  8.     re:
  9.     for(int i=0; i<4; i++)
  10.     {
  11.          r[i]=rand()%10;  //0~9
  12.          for(int j=0; j<i; j++)
  13.          {
  14.              if(r[j]==r[i])
  15.              {
  16.                  i--;
  17.                  break;              
  18.              }
  19.          }
  20.     }
  21.     for(int i=0; i<4; i++)
  22.         cout<<r[i]<<" ";
  23.     cout<<endl;
  24.     system("pause");
  25.     goto re;
  26.     system("pause");
  27.     return 0;
  28. }
複製代碼
http://fs-old.mis.kuas.edu.tw/~s1102137106/music/

TOP

返回列表