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

TOP

返回列表