返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         int money=0;
  8.     int round=1;
  9.     while(true)
  10.     {
  11.            
  12.          system("cls");
  13.     int s[]={0,0,0,0};
  14.     string p[]={"◆","★","▲","●"};
  15.     srand(time(NULL));
  16.     while(true)
  17.     {  
  18.             system("cls");
  19.   cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
  20.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  21.     for(int i=0;i<=3;i++)
  22.     {
  23.        cout<<p[i]<<endl;     
  24.     }
  25.   
  26.     cout<<"\n可用餘額:"<<money<<"元"<<endl;
  27.     int option;
  28.     cout<<"(1)買入 (2)下注 (3)離開\n"<<"請選擇:";
  29.     cin>>option;
  30.     if(option==1)
  31.     {
  32.             int plus;
  33.             cout<<"要儲值多少?"<<endl;
  34.             cin>>plus;
  35.             money=money+plus;
  36.         }
  37.                 }
  38.        
  39.        
  40.     while(true)
  41.     {
  42.           system("cls");
  43.           int r=rand()%4;
  44.           s[r]++;  
  45.           cout<<"比賽進行中"<<endl;
  46.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  47.         for(int j=0; j<=3; j++)
  48.         {
  49.            for(int i=0; i<=s[j]; i++)
  50.                     cout<<" ";
  51.             cout<<p[j]<<endl;     
  52.         }
  53.         if(s[r]==72)
  54.                 break;
  55.         _sleep(0.005);   
  56.     }
  57.     string win;
  58.     for(int i=0; i<=3; i++)
  59.     {
  60.         if(s[i]==73)
  61.         {
  62.             win=p[i];     
  63.         }   
  64.     }
  65.       cout<<"比賽結束"<<win<<"贏"<<endl;
  66.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  67.         for(int j=0; j<=3; j++)
  68.         {
  69.            for(int i=0; i<=s[j]; i++)
  70.             cout<<" ";
  71.             cout<<p[j]<<endl;   
  72.        system("pause");  
  73.        round++;
  74.     }
  75.    
  76. }
  77.        system("pause");
  78.        return 0;
  79. }
複製代碼

TOP

返回列表