返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. using namespace std;
  5. int main()
  6. {
  7.     int time=1;
  8.     while(true)
  9.     {
  10.     int cat1=0, cat2=0, cat3=0, cat4=0, random=0;
  11.     system("cls");
  12.     cout<<"「好事成雙」賽馬場"<< time<<"局"<<endl;
  13.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     system("pause");
  19.     system("cls");
  20.    
  21.     while(cat1!=75 && cat2!=75 && cat3!=75 && cat4!=75)
  22.     {
  23.         random=rand()%4;   //產生0~3之隨機亂數
  24.         if(random==0)
  25.             cat1++;
  26.         else if(random==1)
  27.             cat2++;
  28.             else if(random==2)
  29.             cat3++;
  30.             else if(random==3)
  31.             cat4++;
  32.         cout<<"比賽進行中"<<endl;
  33.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  34.         for(int i=1; i<=cat1; i++)
  35.             cout<<" ";
  36.         cout<<"◆"<<endl;
  37.         for(int i=1; i<=cat2; i++)
  38.             cout<<" ";
  39.         cout<<"★"<<endl;
  40.         for(int i=1; i<=cat3; i++)
  41.             cout<<" ";
  42.         cout<<"▲"<<endl;
  43.         for(int i=1; i<=cat4; i++)
  44.             cout<<" ";
  45.         cout<<"□"<<endl;
  46.         system("cls");      
  47.     }
  48.     time++ ;
  49.     if(cat1==75)
  50.     {
  51.     cout<<"◆成為小小的冠軍"<<endl;
  52.     }
  53.     else if(cat2==75)
  54.     {
  55.     cout<<"★成為小小的冠軍"<<endl;
  56.     }
  57.     else if(cat3==75)
  58.     {
  59.     cout<<"▲成為小小的冠軍"<<endl;
  60.     }
  61.     else
  62.     {
  63.     cout<<"□成為小小的冠軍"<<endl;
  64.     }
  65.      cout<<"------------------------------------------------------------------------| 終點"<<endl;
  66.         for(int i=1; i<=cat1; i++)
  67.             cout<<" ";
  68.         cout<<"◆"<<endl;
  69.         for(int i=1; i<=cat2; i++)
  70.             cout<<" ";
  71.         cout<<"★"<<endl;
  72.         for(int i=1; i<=cat3; i++)
  73.             cout<<" ";
  74.         cout<<"▲"<<endl;
  75.         for(int i=1; i<=cat4; i++)
  76.             cout<<" ";
  77.         cout<<"□"<<endl;
  78.         system("pause");
  79. }
  80.     system("pause");
  81.     return 0;
  82.       
  83. }
複製代碼

TOP

返回列表