返回列表 發帖
本帖最後由 張郁庭 於 2014-4-19 16:34 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int t=1;
  7.     re1:
  8.     int a=0, b=0, c=0, d=0, r;
  9.     system("cls");
  10.     cout<<"﹩財源滾滾賽馬場 ﹩";
  11.     cout<<" 第"<<t<<"局"<<endl;
  12.     cout<<"=========================================================================| 終點"<<endl;
  13.     cout<<"◢1◤"<<endl;
  14.     cout<<"◢2◤"<<endl;
  15.     cout<<"◢3◤"<<endl;
  16.     cout<<"◢4◤"<<endl;
  17.     system("pause");
  18.     system("cls");
  19.     srand(time(NULL));
  20.     while(a!=75 && b!=75 && c!=75 && d!=75)
  21.     {
  22.         r=rand()%4;   
  23.         if(r==0)
  24.             a++;
  25.         else if(r==1)
  26.             b++;
  27.         else if(r==2)
  28.             c++;
  29.         else
  30.             d++;
  31.         cout<<"比賽進行中"<<endl;
  32.         cout<<"=========================================================================| 終點"<<endl;
  33.         for(int i=1; i<=a; i++)
  34.             cout<<" ";
  35.         cout<<"◢1◤"<<endl;
  36.         for(int i=1; i<=b; i++)
  37.             cout<<" ";
  38.         cout<<"◢2◤"<<endl;
  39.         for(int i=1; i<=c; i++)
  40.             cout<<" ";
  41.         cout<<"◢3◤"<<endl;
  42.         for(int i=1; i<=d; i++)
  43.             cout<<" ";
  44.         cout<<"◢4◤"<<endl;   
  45.         system("cls");      
  46.     }
  47.     cout<<"比賽結束";
  48.     if(a==75)
  49.         cout<<" 由◢1◤獲得勝利"<<endl;
  50.     else if(b==75)
  51.         cout<<" 由◢2◤獲得勝利"<<endl;   
  52.     else if(c==75)
  53.         cout<<" 由◢3◤獲得勝利"<<endl;   
  54.     else
  55.         cout<<" 由◢4◤獲得勝利"<<endl;   
  56.     cout<<"------------------------------------------------------------------------| 終點"<<endl;  
  57.     for(int i=1; i<=a; i++)
  58.         cout<<" ";
  59.     cout<<"◢1◤"<<endl;
  60.     for(int i=1; i<=b; i++)
  61.         cout<<" ";
  62.     cout<<"◢2◤"<<endl;
  63.     for(int i=1; i<=c; i++)
  64.         cout<<" ";
  65.     cout<<"◢3◤"<<endl;
  66.     for(int i=1; i<=d; i++)
  67.         cout<<" ";
  68.     cout<<"◢4◤"<<endl;
  69.     system("pause");
  70.     t++;
  71.     goto re1;
  72.     system("pause");
  73.     return 0;   
  74. }
複製代碼

TOP

返回列表