返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int round=1;
  8.     while(true)
  9.     {
  10.          system("cls");
  11.     int s[]={0,0,0,0};
  12.     string p[]={"◆","★","▲","●"};
  13.     srand(time(NULL));
  14.    
  15.   cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
  16.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  17.     for(int i=0;i<=3;i++)
  18.     {
  19.        cout<<p[i]<<endl;     
  20.     }
  21.     while(true)
  22.     {
  23.           system("cls");
  24.           int r=rand()%4;
  25.           s[r]++;  
  26.           cout<<"比賽進行中"<<endl;
  27.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  28.         for(int j=0; j<=3; j++)
  29.         {
  30.            for(int i=0; i<=s[j]; i++)
  31.                     cout<<" ";
  32.             cout<<p[j]<<endl;     
  33.         }
  34.         if(s[r]==72)
  35.                 break;
  36.         _sleep(0.005);   
  37.     }
  38.     string win;
  39.     for(int i=0; i<=3; i++)
  40.     {
  41.         if(s[i]==73)
  42.         {
  43.             win=p[i];     
  44.         }   
  45.     }
  46.       cout<<"比賽結束"<<win<<"贏"<<endl;
  47.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  48.         for(int j=0; j<=3; j++)
  49.         {
  50.            for(int i=0; i<=s[j]; i++)
  51.             cout<<" ";
  52.             cout<<p[j]<<endl;   
  53.        system("pause");  
  54.        round++;
  55.     }
  56.    
  57. }
  58.        system("pause");
  59.        return 0;
  60. }
複製代碼

TOP

返回列表