- include<iostream>
- using namespace std;
- int main()
- {
- int a,b,c;
- int run=0;
- cout<<"$$$支票回收機$$$"<<endl;
- cout<<"遊戲規則說明:"<<endl;
- cout<<"凡是任一欄出現7,獎金雙倍"<<endl;
- cout<<"凡是任兩欄出現7,獎金十倍"<<endl;
- cout<<"凡是任三欄都出現7,獎金一百倍"<<endl;
- cout<<"本次測驗方式: 試試看要多少次才能拉中第二獎"<<endl;
- system("pause");
- srand(time(NULL));
- while(true)
- {
- run++;
- a=rand()%10;
- b=rand()%10;
- c=rand()%10;
- cout<<a<<" "<<b<<" "<<c<<endl;
- if((a==7 && b==7 && c!=7)||(a!=7 && b==7 && c==7)||(a==7 && b!=7 && c==7))
- {
- break;
- }
- }
- cout<<"共計"<<run<<"次"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |