返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main(){
  6.    
  7.     int round=1;
  8.     int balance=0;
  9.     int money=0;
  10.     int betmoney=0;
  11.     int player=0;
  12.     int moneylost=0;
  13.     int moneygained=0;
  14.     re:
  15.     system("cls");
  16.     srand(time(NULL));
  17.     string p[]={"◆","★","▲","●"};
  18.     int s[]={0,0,0,0};
  19.     int r=0;
  20.     int choice;
  21.     cout<<"歡迎光臨騙你錢賽馬場 | 賽馬第"<<round<<"局"<<endl;
  22.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  23.     for(int i=0; i<4; i++)
  24.         cout<<p[i]<<endl;
  25.         
  26.     cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  27.     cout<<"(1)買入(儲值) (2)下注 (3)離開 請選擇:";
  28.     cin>>choice;
  29.    
  30.     if(choice==1){
  31.        cout<<"請問要加值多少錢:";
  32.        cin>>money;
  33.        if(money<=0){
  34.        cout<<"輸入錯誤,請重新輸入!"<<endl;
  35.        _sleep(1500);
  36.        goto re;
  37.        }else
  38.        balance=balance+money;
  39.        goto re;
  40.     }else if(choice==2){
  41.           cout<<"請問要下注多少錢:";
  42.           cin>>betmoney;
  43.           if (betmoney<=0 or betmoney>balance){
  44.                           cout<<"輸入錯誤,請重新輸入!"<<endl;
  45.                                              _sleep(1500);
  46.                      goto re;
  47.           }else{
  48.                 cout<<"(1)◆(2)★(3)▲(4)●請選擇:";
  49.                 }
  50.                 cin>>player;
  51.                 if (player==1 or player==2 or player==3 or player==4){
  52.                           cout<<"比賽即將開始"<<endl;
  53.                           _sleep(2000);
  54.                               
  55.                 }else{
  56.                       cout<<"輸入錯誤,請重新輸入!"<<endl;
  57.                                              _sleep(1500);
  58.                      goto re;
  59.                       }
  60.           }
  61.          
  62.           if(choice == 3){
  63.               if (moneylost>0 and moneylost>moneygained){
  64.                  cout<<"不好意思!讓你損失了"<<moneylost-moneygained<<"元!"<<endl;
  65.                  cout<<"歡迎下次再來!"<<endl;
  66.               }else if (moneygained>0 and moneylost<moneygained){
  67.                        cout<<"恭喜你!這次總共贏了"<<moneygained-moneylost<<"元!"<<endl;
  68.                        cout<<"歡迎下次再來!"<<endl;
  69.               }else if (moneygained=moneylost){
  70.                     cout<<"沒輸沒贏!全身而退!"<<endl;
  71.                  cout<<"歡迎下次再來!"<<endl;
  72.                     }else{
  73.                     cout<<"歡迎下次再來!"<<endl;      
  74.                           }
  75.               system("pause");
  76.               return 0;
  77.           }
  78.    
  79.          
  80.    
  81.     system("pause");
  82.     system("cls");
  83.     while(s[r]<=73)
  84.     {
  85.         r=rand()%4;   //0~3
  86.         s[r]++;
  87.         cout<<"比賽進行中"<<endl;
  88.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  89.         for(int i=0; i<4; i++)
  90.         {
  91.             for(int j=0; j<s[i]; j++)
  92.                 cout<<" ";
  93.             cout<<p[i]<<endl;
  94.         }
  95.         system("cls");
  96.     }
  97.     cout<<"比賽結束!由"<<p[r]<<"獲勝!"<<endl;
  98.     if (player-1 == r){
  99.                 cout<<"你下注的馬贏了!恭喜你贏得"<< betmoney*3<<"元!"<<endl;
  100.                 balance+=betmoney*2;
  101.                 moneygained+=betmoney*2;
  102.                 }else{
  103.                 moneylost+=betmoney;
  104.                 balance-=betmoney;
  105.                 cout<<"你下注的馬輸了!, 損失"<<betmoney<<"元"<<endl;
  106.                 }
  107.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  108.     for(int i=0; i<4; i++)
  109.     {
  110.         for(int j=0; j<s[i]; j++)
  111.             cout<<" ";
  112.         cout<<p[i]<<endl;
  113.     }
  114.     round++;
  115.     system("pause");
  116.     goto re;
  117.     return 0;
  118. }
複製代碼

TOP

返回列表