返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     re:
  8.     system("cls");      
  9.     int s[]={0,0,0,0};   
  10.    string p[]={"○","€","§","◎"};
  11.     srand(time(NULL));
  12.     cout<<"賽馬場"<<endl;
  13.      cout<<"------------------------------------------------------------------------| 終點"<<endl;
  14.        for(int i=0; i<4; i++)
  15.         {     
  16.             cout<<p[i]<<endl;        
  17.         }
  18.     system("pause");
  19.       while(true)
  20.     {
  21.       system("cls");   
  22.         int r=rand()%4;   
  23.         s[r]++;      
  24.         cout<<"比賽"<<endl;
  25.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;  
  26.      
  27.       for(int i=0; i<4; i++)
  28.     {
  29.            
  30.         for(int j=0; j<s[i]; j++)
  31.             cout<<" ";
  32.         cout<<p[i]<<endl;
  33.     }
  34.      if(s[r]==73)
  35.             break;
  36.         _sleep(1);  
  37.     }
  38.     system("cls");
  39.    for(int i=0;i<=3;i++)
  40.         {
  41.                 if(s[i]==73)
  42.                 {
  43.                cout<<"比賽結束!  由 "<<p[i]<<" 先得點!"<<endl;
  44.                 }
  45.           }      
  46.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  47.    
  48.      for(int i=0; i<4; i++)
  49.     {
  50.            
  51.         for(int j=0; j<s[i]; j++)
  52.             cout<<" ";
  53.         cout<<p[i]<<endl;
  54.     }
  55.    
  56.    
  57.     system("pause");
  58.    
  59.     goto re;
  60.     return 0;
  61. }
  62.      
  63.      
  64.      
  65.      
複製代碼

TOP

返回列表