返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int round=1;
  7.     re:
  8.     int s[]={0,0,0,0};
  9.     srand(time(NULL));
  10.     cout<<"「好事成雙」賽馬場第"<<round<<"場"<<endl;
  11.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl;
  16.     system("pause");
  17.     while(true)
  18.     {
  19.         system("cls");
  20.         int r=rand()%4;   
  21.         s[r]++;      
  22.         cout<<"比賽進行中"<<endl;
  23.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  24.         for(int i=0; i<=s[0]; i++)
  25.             cout<<" ";
  26.         cout<<"◆"<<endl;
  27.         for(int i=0; i<=s[1]; i++)
  28.             cout<<" ";
  29.         cout<<"★"<<endl;
  30.         for(int i=0; i<=s[2]; i++)
  31.             cout<<" ";
  32.         cout<<"▲"<<endl;
  33.         for(int i=0; i<=s[3]; i++)
  34.             cout<<" ";
  35.         cout<<"●"<<endl;
  36.         if(s[r]==73)
  37.             break;
  38.                      
  39.     }
  40.     system("cls");
  41.     cout<<"比賽結束"<<endl;
  42.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  43.     for(int i=0; i<=s[0]; i++)
  44.         cout<<" ";
  45.     cout<<"◆"<<endl;
  46.     for(int i=0; i<=s[1]; i++)
  47.         cout<<" ";
  48.     cout<<"★"<<endl;
  49.     for(int i=0; i<=s[2]; i++)
  50.         cout<<" ";
  51.     cout<<"▲"<<endl;
  52.     for(int i=0; i<=s[3]; i++)
  53.         cout<<" ";
  54.     cout<<"●"<<endl;
  55.     round=round+1;
  56.     if(s[0]==73)
  57.         cout<<"恭喜◆獲勝"<<endl;
  58.     else if(s[1]==73)
  59.         cout<<"恭喜★獲勝"<<endl;
  60.     else if(s[2]==73)
  61.         cout<<"恭喜▲獲勝"<<endl;
  62.     else if(s[3]==73)
  63.         cout<<"恭喜●獲勝"<<endl;
  64.     system("pause");
  65.     system("cls");
  66.     goto re;
  67.     system("pause");
  68.     return 0;
  69. }
複製代碼

TOP

返回列表