返回列表 發帖
  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 p[]={"○","€","§","◎"};
  15.     srand(time(NULL));
  16.     cout<<"賽馬場"<<endl;
  17.      cout<<"------------------------------------------------------------------------| 終點"<<endl;
  18.        for(int i=0; i<4; i++)
  19.         {     
  20.             cout<<p[i]<<endl;        
  21.         }
  22.         cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  23.     cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
  24.          cin>>option;
  25.          if(option==1){
  26.             
  27.             cout<<"買入: ";
  28.             cin>>buy;
  29.             balance=balance+buy;        
  30.             goto re;
  31.         }
  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.      
  42.       for(int i=0; i<4; i++)
  43.     {
  44.            
  45.         for(int j=0; j<s[i]; j++)
  46.             cout<<" ";
  47.         cout<<p[i]<<endl;
  48.     }
  49.      if(s[r]==73)
  50.             break;
  51.         _sleep(1);  
  52.     }
  53.     system("cls");
  54.    for(int i=0;i<=3;i++)
  55.         {
  56.                 if(s[i]==73)
  57.                 {
  58.                cout<<"比賽結束!  由 "<<p[i]<<" 先得點!"<<endl;
  59.                 }
  60.           }      
  61.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  62.    
  63.      for(int i=0; i<4; i++)
  64.     {
  65.            
  66.         for(int j=0; j<s[i]; j++)
  67.             cout<<" ";
  68.         cout<<p[i]<<endl;
  69.     }
  70.    
  71.    
  72.     system("pause");
  73.    
  74.     goto re;
  75.     return 0;
  76. }
複製代碼

TOP

返回列表