返回列表 發帖
本帖最後由 許逸瑋 於 2012-2-11 18:11 編輯
  1. #include<iostream>   //當用到標準輸入與輸出時,需插入此標題檔
  2. #include<cstdlib>    //當用到亂數函數時,需插入此標題檔
  3. #include<ctime>      //當用到時間函數時,需插入此標題檔
  4. using namespace std;
  5. int main()
  6. {   
  7.     int a, b, c;
  8.     int run=0;
  9.     cout<<"~~~Money!!! come and go@@~~~"<<endl;
  10.     cout<<"There are the prise description below-3-"<<endl;
  11.     cout<<"if one 7 shows up~"<<"money X2!!"<<endl;
  12.     cout<<"if two 7 shows up~~"<<"money X10!!!"<<endl;
  13.     cout<<"if three 7 shows up~~~"<<"money X100!!!!"<<endl;
  14.     cout<<"this test is going to count how much times does it take to get 777"<<endl;
  15.     system("pause");
  16.     srand(time(NULL));
  17.     while(true)
  18.     {   
  19.         run++;
  20.         a=rand()%10;
  21.         b=rand()%10;
  22.         c=rand()%10;
  23.         cout<<a<<""<<b<<""<<c<<endl;
  24.         if(a==7 && b==7 && c==7)
  25.         {
  26.          break;
  27.         
  28.        }
  29.     }
  30.     cout<<"it runs"<<run<<"times"<<endl;                  
  31.     system("pause");
  32.     return 0;   
  33. }
複製代碼

TOP

返回列表