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

TOP

返回列表