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

TOP

返回列表