返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int m1=0,m2=0,m3=0,c;
  8.     int x=1;
  9. re:
  10.     srand(time(NULL));
  11.     int n[]={0,0,0,0};
  12.     cout<<"「好事成雙」賽馬場第"<<x<<"局"<<endl;
  13.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  14.     string y[]={"◆","★","▲","●"};
  15.     cout<<endl<<endl;
  16. re2:
  17.     cout<<"可用餘額: "<<m1<<"元"<<endl;
  18.     int option;
  19.     cout<<"(1)買入 (2)下注 (3)離開  請選擇:"<<endl;
  20.     cin>>option;
  21.     if(option==1){
  22.         cout<<"買入:";
  23.         cin>>m2;
  24.         if(m2<=0){
  25.             cout<<"輸入錯誤"<<endl;
  26.             _sleep(1500);
  27.             goto re2;
  28.         }
  29.         else {
  30.         m1+=m2;
  31.         goto re2;
  32.         }
  33.     }
  34.     else if(option==2){
  35.         cout<<"下注:";
  36.         cin>>m3;

  37.         if(m3<=0){
  38.             cout<<"輸入錯誤"<<endl;
  39.             _sleep(1500);
  40.             goto re2;
  41.         }

  42.         else if(m1<m3){
  43.             cout<<"可用餘額不足,請先買入!"<<endl;
  44.             _sleep(1500);
  45.             goto re2;
  46.         }
  47.         else if(m1>=m3){
  48.             cout<<"下注幾號 <1>◆ <2>★ <3>▲ <4>● :";
  49.             cin>>c;
  50.             cout<<endl;
  51.             cout<<"比賽即將開始..."<<endl;
  52.         }
  53.     }
  54.     for(int i=0;i<=3;i++)
  55.         cout<<y[i]<<endl;
  56.     int r=0;
  57.     system("pause");
  58.     while(true){
  59.         system("cls");
  60.         r=rand()%4;
  61.         n[r]++;
  62.         cout<<"比賽進行中,第"<<x<<"局"<<endl;
  63.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  64.         for(int i=0;i<=n[0];i++)
  65.             cout<<" ";
  66.             cout<<"◆"<<endl;
  67.         for(int i=0;i<=n[1];i++)
  68.             cout<<" ";
  69.             cout<<"★"<<endl;
  70.         for(int i=0;i<=n[2];i++)
  71.             cout<<" ";
  72.             cout<<"▲"<<endl;
  73.         for(int i=0;i<=n[3];i++)
  74.             cout<<" ";
  75.             cout<<"●"<<endl;
  76.         if(n[r]==73)
  77.             break;

  78.         _sleep(1);

  79.     }system("cls");
  80.     cout<<"比賽結束由"<<y[r]<<"先馳得點!"<<endl;
  81.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  82.         for(int i=0;i<=n[0];i++)
  83.             cout<<" ";
  84.             cout<<"◆"<<endl;
  85.         for(int i=0;i<=n[1];i++)
  86.             cout<<" ";
  87.             cout<<"★"<<endl;
  88.         for(int i=0;i<=n[2];i++)
  89.             cout<<" ";
  90.             cout<<"▲"<<endl;
  91.         for(int i=0;i<=n[3];i++)
  92.             cout<<" ";
  93.             cout<<"●"<<endl;
  94.     system("pause");
  95.     x++;
  96.     system("cls");
  97.     goto re;
  98.     return 0;
  99. }
複製代碼

TOP

返回列表