返回列表 發帖
  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 option;
  10.         int buy;
  11.         re:
  12.         system("cls");
  13.         int s[]={0,0,0,0};
  14.         string h[]={"◆","★","▲","●"};
  15.         srand(time(NULL));       
  16.     cout<<"「好事成雙」賽馬場,第"<<round<<"局"<<endl;
  17.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  18.         for(int i=0;i<4;i++)
  19.         {
  20.                 cout<<h[i]<<endl;
  21.         }
  22.         cout<<"可用餘額"<<balance<<"元";
  23.         cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  24.         cin>>option;
  25.         if(option==1)
  26.         {       
  27.                 cout<<"你要儲值多少元?";
  28.                 cin>>buy;
  29.                 cout<<"買入"<<buy<<"元";
  30.                 balance=buy+balance;
  31.                 goto re;
  32.         }
  33.     system("pause");
  34.     while(true)
  35.         {
  36.         system("cls");
  37.         int r=rand()%4;
  38.         s[r]++;
  39.         cout<<"比賽進行中"<<endl;
  40.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  41.         for(int j=0;j<4;j++)
  42.         {
  43.                 for(int i=0;i<s[j];i++)
  44.                 {
  45.                 cout<<" ";
  46.                 }
  47.                 cout<<h[j]<<endl;
  48.         }
  49.        
  50.        

  51.         if(s[r]==73)
  52.         {
  53.                 break;
  54.                 _sleep(50);
  55.         }

  56.         }
  57.         system("cls");
  58.                 for(int i=0;i<=3;i++)
  59.         {
  60.                 if(s[i]==73)
  61.                 {
  62.                          cout<<"比賽結束!  由 "<<h[i]<<" 先馳得點!"<<endl;
  63.                 }
  64.                
  65.         }
  66.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  67.         for(int x=0;x<4;x++)
  68.         {
  69.                 for(int y=0;y<s[x];y++)
  70.                 {
  71.                 cout<<" ";
  72.                 }
  73.         cout<<h[x]<<endl;
  74.         }


  75.         system("pause");
  76.             round++;
  77.         goto re;
  78.     return 0;
  79. }
複製代碼

TOP

返回列表