返回列表 發帖
  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 h[]={"◆","★","▲","●"};
  12.         srand(time(NULL));       
  13.     cout<<"「好事成雙」賽馬場,第"<<round<<"局"<<endl;
  14.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  15.         for(int i=0;i<4;i++)
  16.         {
  17.                 cout<<h[i]<<endl;
  18.         }
  19.     system("pause");
  20.     while(true)
  21.         {
  22.         system("cls");
  23.         int r=rand()%4;
  24.         s[r]++;
  25.         cout<<"比賽進行中"<<endl;
  26.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  27.         for(int j=0;j<4;j++)
  28.         {
  29.                 for(int i=0;i<s[j];i++)
  30.                 {
  31.                 cout<<" ";
  32.                 }
  33.                 cout<<h[j]<<endl;
  34.         }
  35.        
  36.        

  37.         if(s[r]==73)
  38.         {
  39.                 break;
  40.                 _sleep(50);
  41.         }

  42.         }
  43.         system("cls");
  44.                 for(int i=0;i<=3;i++)
  45.         {
  46.                 if(s[i]==73)
  47.                 {
  48.                          cout<<"比賽結束!  由 "<<h[i]<<" 先馳得點!"<<endl;
  49.                 }
  50.                
  51.         }
  52.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  53.         for(int x=0;x<4;x++)
  54.         {
  55.                 for(int y=0;y<s[x];y++)
  56.                 {
  57.                 cout<<" ";
  58.                 }
  59.         cout<<h[x]<<endl;
  60.         }


  61.         system("pause");
  62.             round++;
  63.         goto re;
  64.     return 0;
  65. }
複製代碼

TOP

返回列表