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

TOP

返回列表