返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.    int a, b, c;
  8.    int money1, money, choice;
  9.    cout<<"$$$ 歡迎使用吃角子老虎虛擬遊戲機 $$$"<<endl;
  10.    cout<<"遊戲規則說明:"<<endl;
  11.    cout<<"玩一次10元"<<endl;
  12.    cout<<"任一欄出現7 --> 獎金變兩倍"<<endl;
  13.    cout<<"任兩欄出現7 --> 獎金變十倍"<<endl;
  14.    cout<<"三欄都出現7 --> 獎金變一百倍"<<endl;
  15.    cout<<"請投幣: ";
  16.    cin>>money1;
  17.    money=money1;
  18.    start:
  19.    srand(time(NULL));
  20.    a=rand()%10;
  21.    b=rand()%10;
  22.    c=rand()%10;
  23.    cout<<"轉啊轉..."<<endl;
  24.    cout<<a<<" "<<b<<" "<<c<<endl;
  25.        if(a==7 && b==7 && c==7)
  26.        {
  27.             cout<<"哇!!! 第一特獎!!!"<<endl;
  28.             cout<<"你贏了1000元!"<<endl;
  29.             money=money+1000;
  30.        }
  31.        else if((a==7 && b==7 && c!=7)||(a==7 && b!=7 && c==7)||(a!=7 && b==7 && c==7))
  32.        {
  33.             cout<<"恭喜你! 中了二獎!"<<endl;
  34.             cout<<"你贏了100元!"<<endl;
  35.             money=money+100;
  36.        }
  37.        else if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
  38.        {
  39.             cout<<"恭喜你! 中了三獎!"<<endl;
  40.             cout<<"雖然只贏了10元, 還是很棒喔!"<<endl;
  41.             money=money+10;
  42.        }else
  43.        {
  44.             cout<<"哎呀! 損失了10元!"<<endl;
  45.             money=money-10;
  46.             if(money==0)
  47.             {
  48.                  cout<<"你怎麼把錢輸光了! 一毛不剩!"<<endl;
  49.                  cout<<"強制驅離!"<<endl;
  50.                  goto end;            
  51.             }
  52.        }
  53.    cout<<"目前餘額: "<<money<<"元"<<endl;
  54.    cout<<"1-再玩一把  2-見好就收"<<endl;
  55.    cin>>choice;
  56.    if(choice==1)
  57.    {
  58.        goto start;
  59.    }else
  60.    {
  61.        goto end;
  62.    }
  63.    end:
  64.    if(money-money1>0)
  65.    {
  66.        cout<<"太好囉! 你今天共贏了"<<money-money1<<"元!"<<endl;               
  67.    }else if(money-money1<0)
  68.    {
  69.        cout<<"太遺憾了! 你今天共輸掉了"<<money1-money<<"元!"<<endl;  
  70.    }else
  71.    {
  72.        cout<<"沒輸沒贏, 全身而退!"<<endl;
  73.    }   
  74.    system("pause");
  75.    return 0;
  76. }
複製代碼

TOP

返回列表