返回列表 發帖
本帖最後由 黃博鴻 於 2012-10-1 21:43 編輯
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int times=0;
  6.     int a, b, c;
  7.     double money, omoney, bet;
  8.     int choice;
  9.     cout<<"***歡迎使用吃角子老虎機 V1.0***"<<endl;
  10.     cout<<"遊戲規則如下:"<<endl
  11.         <<"中三獎, 任一欄出現7 --> 贏得下注金兩倍的獎金"<<endl
  12.         <<"中二獎, 任兩欄出現7 --> 贏得下注金十倍的獎金"<<endl
  13.         <<"中第一特獎, 三欄都出現7 --> 贏得下注金一百倍的獎金"<<endl<<endl;
  14.     begin:
  15.     cout<<"請輸入你所帶的錢: ";
  16.     cin>>money;
  17.     omoney=money;
  18.     if(money==0)
  19.     {
  20.      cout<<"你是不是想玩免費的啊?"<<endl;
  21.      goto begin;            
  22.     }else if(money>100000)
  23.     {
  24.      cout<<"你是不是錢太多啊?"<<endl;
  25.      goto begin;            
  26.     }
  27.     start:
  28.     cout<<"請輸入下注金額: ";
  29.     cin>>bet;
  30.     if(bet>money)
  31.     {
  32.      cout<<"你是不是頭殼壞掉了?"<<endl;
  33.      goto start;            
  34.     }
  35.     times++;
  36.     srand(time(NULL));
  37.     system("cls");
  38.     for(int i=1; i<=50; i++)
  39.     {
  40.       a=rand()%10;
  41.       b=rand()%10;
  42.       c=rand()%10;
  43.       cout<<a<<" "<<b<<" "<<c<<" 我轉我轉我轉轉轉!"<<endl;
  44.       system("cls");      
  45.     }   
  46.      cout<<a<<" "<<b<<" "<<c<<" 噹噹!"<<endl<<endl;
  47.      if((a==7 && b!=7 && c!=7)||(a!=7 && b==7 && c!=7)||(a!=7 && b!=7 && c==7))
  48.      {
  49.       cout<<"恭喜你,中了三獎!";
  50.       money=money+bet*2;
  51.       cout<<"你獲得獎金"<<bet*2<<"元, 所剩餘額為"<<money<<"元"<<endl;  
  52.      }else if((a==7 && b==7 && c!=7)||(a!=7 && b==7 && c==7)||(a==7 && b!=7 && c==7))
  53.      {
  54.       cout<<"恭喜你,中了二獎!";
  55.       money=money+bet*10;
  56.       cout<<"你獲得獎金"<<bet*10<<"元, 所剩餘額為"<<money<<"元"<<endl;     
  57.      }else if(a==7 && b==7 && c==7)
  58.      {
  59.       cout<<"恭喜你,中了第一特獎!";
  60.       money=money+bet*100;
  61.       cout<<"你獲得獎金"<<bet*100<<"元, 所剩餘額為"<<money<<"元"<<endl;     
  62.      }
  63.     else
  64.     {
  65.         money=money-bet;
  66.         if(money==0)
  67.         {
  68.               cout<<"哎呀! 你怎麼把錢輸光了!"<<endl;
  69.               cout<<"強制驅離!"<<endl;
  70.               goto end;      
  71.         }
  72.         cout<<"沒中!"<<endl;
  73.         cout<<"損失"<<bet<<"元, 所剩餘額"<<money<<"元!"<<endl;
  74.     }  
  75.       cout<<endl;
  76.      choose:
  77.      cout<<"1-再搏一回 2-見好就收"<<endl;
  78.      cout<<"請選擇"<<endl;
  79.      cin>>choice;
  80.      if(choice==1)
  81.      {
  82.       goto start;   
  83.      }else if(choice==2)
  84.      {
  85.       goto end;     
  86.      }else
  87.      {
  88.       cout<<"代碼錯誤"<<endl;
  89.       goto choose;   
  90.      }
  91.      end:   
  92.      cout<<"***戰績***"<<endl;
  93.      cout<<"總共搏了"<<times<<"回, ";
  94.      if(omoney<money)
  95.      {
  96.       cout<<"贏了"<<money-omoney<<"元"<<endl;
  97.      }
  98.      else if(omoney>money)
  99.      {
  100.       cout<<"輸了"<<omoney-money<<"元"<<endl;   
  101.      }else
  102.      {
  103.       cout<<"沒輸沒贏, 全身而退"<<endl;
  104.      }
  105.       
  106.     system("pause");
  107.     return 0;
  108. }
複製代碼

TOP

返回列表