返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.    int a,b,c;
  8.    int money;
  9.    int choice;
  10.    cout<<"$$$ 吃角子老虎機中獎機率評估程式 $$$"<<endl;
  11.    cout<<"中獎規則說明:"<<endl;
  12.    cout<<"任一欄出現7 --> 獎金變兩倍"<<endl;
  13.    cout<<"任兩欄出現7 --> 獎金變十倍"<<endl;
  14.    cout<<"三欄都出現7 --> 獎金變一百倍"<<endl;
  15.    cout<<"請投幣: ";
  16.    cin>>money;
  17.    start:
  18.    srand(time(NULL));
  19.        a=rand()%10;
  20.        b=rand()%10;
  21.        c=rand()%10;
  22.        cout<<"~~~轉ㄚ轉~~~"<<endl;
  23.        cout<<a<<" "<<b<<" "<<c<<endl;
  24.        if(a==7 && b==7 && c==7)
  25.        {
  26.             cout<<"恭喜你獲得第一特獎"<<endl;
  27.             cout<<"你獲得1000元"<<endl;
  28.             money=money+1000 ;
  29.        }
  30.        if((a==7 && b==7 && c!=7)||(a==7 && b!=7 && c==7)||(a!=7 && b==7 && c==7))
  31.        {
  32.             cout<<"恭喜你獲得第二特獎"<<endl;
  33.             cout<<"你獲得100元"<<endl;
  34.             money=money+100 ;
  35.        }
  36.        if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
  37.        {
  38.             cout<<"恭喜你獲得第三特獎"<<endl;
  39.             cout<<"你獲得10元"<<endl;
  40.             money=money+10;
  41.        }
  42.        else
  43.        {
  44.            cout<<"恭喜你沒中獎"<<endl;
  45.            cout<<"獲得-10元"<<endl;
  46.            money=money-10;
  47.        }
  48.    cout<<"目前餘額:"<<money<<"元"<<endl;
  49.    cout<<"1:再玩一把  2:見好就收"<<endl;
  50.    cin>>choice;
  51.    if(choice==1)
  52.    {
  53.                 goto start;
  54.    } else
  55.    {
  56.          goto end;
  57.    }
  58.    end:

  59.    system("pause");
  60.    return 0;
  61. }
複製代碼

TOP

返回列表