返回列表 發帖
本帖最後由 尤泓鈞 於 2012-2-18 16:19 編輯
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a,b,c;
  6.     int run=0;
  7.   cout<<"$$$支票回收機$$$"<<endl;
  8.   cout<<"遊戲規則說明:"<<endl;
  9.   cout<<"凡是任一欄出現7,獎金雙倍"<<endl;
  10.   cout<<"凡是任兩欄出現7,獎金十倍"<<endl;
  11.   cout<<"凡是任三欄都出現7,獎金一百倍"<<endl;
  12.   cout<<"本次測驗方式: 試試看要多少次才能拉中第三獎"<<endl;
  13.   system("pause");
  14.   srand(time(NULL));
  15.   while(true)
  16.   {
  17.    run++;         
  18.   a=rand()%10;
  19.   b=rand()%10;
  20.   c=rand()%10;
  21.   cout<<a<<"  "<<b<<"  "<<c<<endl;
  22.   if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
  23.   {
  24.           break;
  25.   }
  26.   }
  27.   cout<<"共計"<<run<<"次"<<endl;
  28.     system("pause");
  29.     return 0;   
  30. }
複製代碼

TOP

返回列表