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

TOP

返回列表