返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         int round=1;        //局數
  8.       
  9.     re:
  10.     system("cls");
  11.     srand(time(NULL));
  12.     int s[]={0,0,0,0};        //存放進度用的
  13.     string p[]={"◆","★","▲","●"};        //存放馬用的
  14.     int r=0;
  15.     cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
  16.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  17.     for(int i=0; i<4; i++)
  18.         cout<<p[i]<<endl;        //把馬印出來
  19.     system("pause");
  20.     system("cls");        //清空畫面
  21.     while(s[r]<=73)        //開始賽馬
  22.     {
  23.         r=rand()%4;   //0~3        (抽馬)
  24.         s[r]++;        //看電腦抽到哪隻馬就+1
  25.         cout<<"比賽進行中"<<endl;
  26.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  27.         for(int i=0; i<4; i++)
  28.         {
  29.             for(int j=0; j<s[i]; j++)
  30.                 cout<<" ";        //印空格(看進度是多少就印多少空格)
  31.             cout<<p[i]<<endl;        //把馬印出來
  32.         }
  33.         _sleep(50);
  34.         system("cls");
  35.     }
  36.     cout<<"比賽結束!  由 "<<p[r]<<" 先馳得點!"<<endl;
  37.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  38.     for(int i=0; i<4; i++)
  39.     {
  40.            
  41.         for(int j=0; j<s[i]; j++)
  42.             cout<<" ";
  43.         cout<<p[i]<<endl;
  44.     }
  45.     system("pause");
  46.     round++;        //局數+1
  47.     goto re;
  48.     return 0;
  49. }
複製代碼

TOP

  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.     srand(time(NULL));
  11.     int s[]={0,0,0,0};        
  12.     string p[]={"◆","★","▲","●"};        
  13.     int r=0;
  14.     cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
  15.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  16.     for(int i=0; i<4; i++)
  17.     cout<<p[i]<<endl;      
  18.     system("pause");
  19.     system("cls");        
  20.     while(s[r]<=73)        
  21.     {
  22.     r=rand()%4;   
  23.     s[r]++;      
  24.     cout<<"比賽進行中"<<endl;
  25.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  26.     for(int i=0; i<4; i++)
  27.     {
  28.     for(int j=0; j<s[i]; j++)
  29.     cout<<" ";        
  30.     cout<<p[i]<<endl;      
  31.     }
  32.     _sleep(50);
  33.     system("cls");
  34.     }
  35.     cout<<"比賽結束!  由 "<<p[r]<<" 先馳得點!"<<endl;
  36.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  37.     for(int i=0; i<4; i++)
  38.     {     
  39.     for(int j=0; j<s[i]; j++)
  40.     cout<<" ";
  41.     cout<<p[i]<<endl;
  42.     }
  43.     system("pause");
  44.     round++;        
  45.     goto re;
  46.     return 0;
  47. }
複製代碼

TOP

返回列表