返回列表 發帖
  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.     srand(time(NULL));
  14.     int s[]={0,0,0,0};        
  15.     string p[]={"◆","★","▲","●"};        
  16.     int r=0;
  17.     cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
  18.     cout<<"--------------------------------------------------------- ---------------| 終點"<<endl;
  19.     for(int i=0; i<4; i++)
  20.     cout<<p[i]<<endl;      
  21.     cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  22.     cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
  23.     cin>>option;
  24.     if(option==1){
  25.     cout<<"買入: ";
  26.     cin>>buy;
  27.     balance=balance+buy;      
  28.     goto re;
  29.     }
  30.     system("pause");
  31.     system("cls");        
  32.     while(s[r]<=73)        
  33.     {
  34.     r=rand()%4;   
  35.     s[r]++;        
  36.     cout<<"比賽進行中"<<endl;
  37.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  38.     for(int i=0; i<4; i++)
  39.     {
  40.     for(int j=0; j<s[i]; j++)
  41.     cout<<" ";        
  42.     cout<<p[i]<<endl;        
  43.     }
  44.     _sleep(50);
  45.     system("cls");
  46.     }
  47.     cout<<"比賽結束!  由 "<<p[r]<<" 先馳得點!"<<endl;
  48.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  49.     for(int i=0; i<4; i++)
  50.     {
  51.     for(int j=0; j<s[i]; j++)
  52.     cout<<" ";
  53.     cout<<p[i]<<endl;
  54.     }
  55.     system("pause");
  56.     round++;        
  57.     goto re;
  58.     return 0;
  59. }
複製代碼

TOP

返回列表