返回列表 發帖

賽馬程式 "兩匹馬PK"

本帖最後由 歐柏罕 於 2017-10-3 19:24 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re1:
  7.     int a=0, b=0, c=0, d=0, r;
  8.     system("cls");
  9.     cout<<"「好事成雙」賽馬場"<<endl;
  10.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  11.     cout<<"◆"<<endl;
  12.     cout<<"★"<<endl;
  13.     cout<<"▲"<<endl;
  14.     cout<<"●"<<endl;
  15.     system("pause");
  16.     system("cls");
  17.    
  18.     while(a!=75 && b!=75 && c!=75 && d!=75)
  19.     {
  20.         r=rand()%4;   //產生0~3之隨機亂數
  21.         if(r==0)
  22.             a++;
  23.         else if(r==1)
  24.             b++;
  25.         cout<<"比賽進行中"<<endl;
  26.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  27.         for(int i=1; i<=a; i++)
  28.             cout<<" ";
  29.         cout<<"◆"<<endl;
  30.         for(int i=1; i<=b; i++)
  31.             cout<<" ";
  32.         cout<<"★"<<endl;
  33.         system("cls");      
  34.     }
  35.    
  36.     goto re1;
  37.     system("pause");
  38.     return 0;
  39.       
  40. }
複製代碼

返回列表