返回列表 發帖
本帖最後由 李知易 於 2015-8-29 11:06 編輯
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int n=1;
  7.    re:      
  8.    int a=0,b=0,c=0,d=0,r;            
  9.    system("cls");   
  10.    srand(time(NULL));
  11.    cout<<"[馬到成功\] 賽馬場 第"<<n<<"場"<<endl;
  12.    cout<<"--------------------------------------------------------------------------|終點"<<endl;
  13.    cout<<"#1"<<endl;
  14.    cout<<"#2"<<endl;
  15.    cout<<"#3"<<endl;
  16.    cout<<"#4"<<endl;
  17.    cout<<endl;
  18.    cout<<"#1: 閃電"<<endl;
  19.    cout<<"#2: 傑哥"<<endl;
  20.    cout<<"#3: 內褲哥"<<endl;
  21.    cout<<"#4: 辣椒妹"<<endl;
  22.    cout<<endl;
  23.     system("pause");
  24.     system("cls");   
  25.   
  26.     while(a<=35 && c<=35 && b<=35 && d<=35)
  27.     {
  28.         r=rand()%4+1;
  29.         if(r==1)
  30.             a++;
  31.         else if(r==2)
  32.                b++;
  33.         else if(r==3)
  34.                c++;
  35.         else
  36.             d++;
  37.         cout<<"比賽進行中"<<endl;
  38.         cout<<"--------------------------------------------------------------------------|終點"<<endl;
  39.         for(int i=0;i<=a;i++)
  40.             cout<<"  ";
  41.         cout<<"#1"<<endl;
  42.         for(int i=0;i<=b;i++)
  43.             cout<<"  ";
  44.         cout<<"#2"<<endl;
  45.         for(int i=0;i<=c;i++)
  46.             cout<<"  ";
  47.         cout<<"#3"<<endl;
  48.         for(int i=0;i<=d;i++)
  49.             cout<<"  ";
  50.         cout<<"#4"<<endl;

  51.             
  52.         system("cls");
  53.                        
  54.     }
  55.        if(a>=35)
  56.        {
  57.            cout<<"比賽結束  #1 閃電 贏了"<<endl;
  58.       
  59.        }   
  60.        else if(b>=35)
  61.        {
  62.             cout<<"比賽結束  #2 傑哥 贏了"<<endl;
  63.       
  64.       }
  65.       else if(c>=35)
  66.       {
  67.             cout<<"比賽結束  #3 內褲哥 贏了"<<endl;
  68.       }
  69.       else
  70.       {
  71.            cout<<"比賽結束  #4  辣椒妹 贏了"<<endl;
  72.       
  73.       }                     
  74.      
  75.      cout<<"--------------------------------------------------------------------------|終點"<<endl;
  76.      for(int i=0;i<=a;i++)
  77.          cout<<"  ";
  78.      cout<<"#1"<<endl;
  79.      for(int i=0;i<=b;i++)
  80.          cout<<"  ";
  81.      cout<<"#2"<<endl;
  82.      for(int i=0;i<=c;i++)
  83.          cout<<"  ";
  84.      cout<<"#3"<<endl;
  85.      for(int i=0;i<=d;i++)
  86.          cout<<"  ";
  87.      cout<<"#4"<<endl;
  88.      
  89.    cout<<endl;
  90.    cout<<"#1: 閃電"<<endl;
  91.    cout<<"#2: 傑哥"<<endl;
  92.    cout<<"#3: 內褲哥"<<endl;
  93.    cout<<"#4: 辣椒妹"<<endl;
  94.    cout<<endl;
  95.    n++;
  96.    
  97. system("pause");

  98. goto re;
  99. return 0;
  100. }
複製代碼

TOP

返回列表