返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n=1, balance=0;
  8.     int option, buying, bet, player, all;
  9.     re:
  10.         system("cls");
  11.         srand(time(NULL));
  12.         int s[]={0,0,0,0};
  13.         string p[]={"◆","★","▲","●"};
  14.         int r=0;
  15.         cout<<"本賽馬場 第"<<n<<"局"<<endl;
  16.         cout<<"-------------------------------------------------------------------------  終點"<<endl;
  17.         for(int i=0; i<4; i++){
  18.             cout<<p[i]<<endl;
  19.         }
  20.         cout<<"可用餘額"<<balance<<"元"<<endl;
  21.         cout<<"請選擇 (1)買入(2)下注(3)離開"<<endl;
  22.         cin>>option;
  23.         if(option==1){
  24.             cout<<"買入 :"<<endl;
  25.             cin>>buying;
  26.             if(buying<=0){
  27.                 cout<<"輸入錯誤"<<endl;
  28.                 _sleep(1500);
  29.                 goto re;
  30.             }
  31.             balance+=buying;
  32.             all+=buying;
  33.             goto re;
  34.         }
  35.         else if(option==2){
  36.             cout<<"下注 :"<<endl;
  37.             cin>>bet;
  38.             if(bet>balance){
  39.                 cout<<"餘額不足"<<endl;
  40.                 _sleep(1500);
  41.                 goto re;
  42.             }
  43.             if(bet<=0){
  44.                 cout<<"輸入錯誤"<<endl;
  45.                 _sleep(1500);
  46.                 goto re;
  47.             }
  48.             cout<<"請選擇  (1)◆ (2)★ (3)▲ (4)●"<<endl;
  49.             cin>>player;
  50.             cout<<"比賽即將開始"<<endl;
  51.         }
  52.         else if(option==3){
  53.             goto end;
  54.         }
  55.         else{
  56.             cout<<"輸入錯誤"<<endl;
  57.             _sleep(1500);
  58.             goto re;
  59.         }
  60.         system("pause");
  61.         system("cls");
  62.         while(s[r]<=73){
  63.         r=rand()%4;
  64.         s[r]++;
  65.         cout<<"比賽進行中"<<endl;
  66.         cout<<"-------------------------------------------------------------------------  終點"<<endl;
  67.         for(int i=0; i<4; i++){
  68.             for(int j=0; j<s[i]; j++)
  69.             cout<<" ";
  70.             cout<<p[i]<<endl;
  71.         }
  72.         _sleep(50);
  73.         system("cls");
  74.         }
  75.         cout<<"最終由"<<p[r]<<"先馳得點"<<endl;
  76.         cout<<"比賽結束"<<endl;
  77.         cout<<"-------------------------------------------------------------------------  終點"<<endl;
  78.         for(int i=0; i<4; i++){
  79.             for(int j=0; j<s[i]; j++)
  80.             cout<<" ";
  81.             cout<<p[i]<<endl;
  82.         }
  83.         if(r+1==player){
  84.             balance+=bet*3;
  85.             cout<<"贏得"<<bet*3<<"元"<<endl;
  86.         }
  87.         else{
  88.             balance-=bet;
  89.             cout<<"損失"<<bet<<"元"<<endl;
  90.         }
  91.         system("pause");
  92.         n++;
  93.         goto re;
  94.         end:
  95.             if(all==balance){
  96.                 cout<<"沒輸沒贏"<<endl;
  97.             }
  98.             if(all<balance){
  99.                 cout<<"恭喜 這次賺了"<<balance-all<<"元"<<endl;
  100.             }
  101.             if(all>balance){
  102.                 cout<<"可惜 這次損失"<<all-balance<<"元"<<endl;
  103.             }
  104.             cout<<"慢走"<<endl;
  105.             _sleep(1500);
  106.             return 0;

  107. }
複製代碼

TOP

返回列表