返回列表 發帖
本帖最後由 黃茂勛 於 2016-10-15 11:42 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     srand(time(NULL));
  7.     re:
  8.     system("cls");                  
  9.     string n[]={"◆","★","▲","●"};
  10.     int s[]={0,0,0,0};
  11.     cout<<"「場賽馬賽場馬」賽馬場"<<endl;
  12.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  13.     for(int i=0; i<4; i++)
  14.         cout<<n[i]<<endl;
  15.     system("pause");
  16.     while(true)
  17.     {     
  18.          int r=rand()%4;
  19.          s[r]++;
  20.          cout<<"比賽進行中"<<endl;
  21.          cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  22.          for(int i=0; i<4; i++)
  23.          {
  24.              for(int j=0; j<s[i]; j++)
  25.                  cout<<" ";
  26.              cout<<n[i]<<endl;   
  27.          }  
  28.          _sleep(10);
  29.          system("cls");  
  30.          if(s[r]==76)
  31.             break;
  32.     }
  33.     cout<<"比賽結束"<<endl;
  34.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  35.     for(int i=0; i<4; i++)
  36.     {
  37.         for(int j=0; j<s[i]; j++)
  38.             cout<<" ";
  39.         cout<<n[i]<<endl;   
  40.     }
  41.     system("pause");
  42.     goto re;
  43.     return 0;   
  44. }
複製代碼

TOP

返回列表