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

TOP

返回列表