返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include <time.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     int g=1,rest=0;
  8.     re:
  9.     int a=0,b=0,c=0,d=0,h,option,buyin=0;
  10.     cout<<"「好事成雙」賽馬場 第"<<g<<"局"<<endl;
  11.     cout<<"|--------------------------------------------------|"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl;
  16.     cout<<"可用餘額"<<rest<<"元"<<endl<<endl;
  17.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  18.     cin>>option;
  19.     if(option==1)
  20.     {
  21.           cout<<"買入金額:"<<buyin;
  22.           cin>>buyin;
  23.           rest+=buyin;
  24.           goto re;
  25.     }else if(option==2)
  26.     {}else if(option==3)
  27.     {}else
  28.     {
  29.           cout<<"輸入錯誤"<<endl;
  30.           goto re;
  31.     }
  32.     system("pause");
  33.     srand(time(NULL));
  34.     while(a!=50 && b!=50 && c!=50 && d!=50)
  35.     {
  36.           cout<<"賽馬進行中"<<endl;
  37.           cout<<"|--------------------------------------------------|"<<endl;
  38.           h = rand()%4+1;
  39.           if(h==1)
  40.              a++;
  41.           if(h==2)
  42.              b++;
  43.           if(h==3)
  44.              c++;
  45.           if(h==4)
  46.              d++;
  47.             
  48.           for(int i=0;i<=a;i++)
  49.           {
  50.                   cout<<" ";
  51.           }
  52.           cout<<"◆"<<endl;
  53.           for(int i=0;i<=b;i++)
  54.           {
  55.                   cout<<" ";
  56.           }
  57.           cout<<"★"<<endl;
  58.           for(int i=0;i<=c;i++)
  59.           {
  60.                   cout<<" ";
  61.           }
  62.           cout<<"▲"<<endl;
  63.           for(int i=0;i<=d;i++)
  64.           {
  65.                   cout<<" ";
  66.           }
  67.           cout<<"●"<<endl;
  68.           system("cls");
  69.     }
  70.     if(a==50)
  71.     {
  72.     cout<<"比賽結束 由◆先馳得點"<<endl;
  73.     }
  74.     if(b==50)
  75.     {
  76.     cout<<"比賽結束 由★先馳得點"<<endl;
  77.     }
  78.     if(c==50)
  79.     {
  80.     cout<<"比賽結束 由▲先馳得點"<<endl;
  81.     }
  82.     if(d==50)
  83.     {
  84.     cout<<"比賽結束 由●先馳得點"<<endl;
  85.     }
  86.     cout<<"|--------------------------------------------------|"<<endl;
  87.     for(int i=0;i<=a;i++)
  88.     {
  89.         cout<<" ";
  90.     }
  91.     cout<<"◆"<<endl;
  92.     for(int i=0;i<=b;i++)
  93.     {
  94.         cout<<" ";
  95.     }
  96.     cout<<"★"<<endl;
  97.     for(int i=0;i<=c;i++)
  98.     {
  99.         cout<<" ";
  100.     }
  101.     cout<<"▲"<<endl;
  102.     for(int i=0;i<=d;i++)
  103.     {     
  104.         cout<<" ";
  105.     }
  106.     cout<<"●"<<endl;
  107.     system("pause");
  108.     system("cls");
  109.     g++;
  110.     goto re;
  111.    
  112.     system("pause");
  113.     return 0;
  114. }
複製代碼
回復 1# 陳品肇

TOP

返回列表