返回列表 發帖
本帖最後由 林以諾 於 2013-10-26 14:23 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   int winner;
  7.   int a=0,b=0,c=0,d=0,r;
  8.   cout<<"『以諾帥哥』賽馬場!!"<<endl;
  9.   cout<<"-----------------------------------------------------------|終點"<<endl;
  10.   cout<<"◥1◣"<<endl;
  11.   cout<<"◥2◣"<<endl;
  12.   cout<<"◥3◣"<<endl;
  13.   cout<<"◥4◣"<<endl;
  14.   system("pause");
  15.   srand(time(NULL));
  16.   while((a!=60)&&(b!=60)&&(c!=60)&&(d!=60))
  17.   {
  18.              r=rand()%4;
  19.              if(r==0)
  20.               a++;     
  21.              else if(r==1)
  22.               b++;   
  23.              else if(r==2)
  24.               c++;   
  25.              else
  26.               d++;   
  27.              cout<<"比賽進行中....";
  28.              cout<<endl<<"-----------------------------------------------------------|終點"<<endl;
  29.                for(int i=1;i<=a;i++)
  30.                cout<<" ";
  31.                cout<<"◥1◣"<<endl;     
  32.                for(int i=1;i<=b;i++)
  33.                cout<<" ";
  34.                cout<<"◥2◣"<<endl;
  35.                for(int i=1;i<=c;i++)
  36.                cout<<" ";
  37.                cout<<"◥3◣"<<endl;     
  38.                for(int i=1;i<=d;i++)
  39.                cout<<" ";
  40.                cout<<"◥4◣"<<endl;
  41.                system("cls");                             
  42.                                            }
  43.                if(a>b&&a>c&&a>d)
  44.                winner=1;
  45.                else if(b>a&&b>c&&b>d)
  46.                winner=2;
  47.                else if(c>a&&c>b&&c>d)
  48.                winner=3;
  49.                else
  50.                winner=4;
  51.                cout<<"比賽結束!由"<<winner<<"號選手獲得勝利"<<endl;
  52.                cout<<endl<<"-----------------------------------------------------------|終點"<<endl;
  53.                for(int i=1;i<=a;i++)
  54.                cout<<" ";
  55.                cout<<"◥1◣"<<endl;     
  56.                for(int i=1;i<=b;i++)
  57.                cout<<" ";
  58.                cout<<"◥2◣"<<endl;
  59.                for(int i=1;i<=c;i++)
  60.                cout<<" ";
  61.                cout<<"◥3◣"<<endl;     
  62.                for(int i=1;i<=d;i++)
  63.                cout<<" ";
  64.                cout<<"◥4◣"<<endl;                                       
  65.   system("pause");
  66.   return 0;  
  67. }
複製代碼

TOP

返回列表