返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,money=0;
  7.     re:
  8.     int a=0, b=0, c=0, d=0, r, option, buy;
  9.     system("cls");
  10.     cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
  11.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  12.     cout<<"◆"<<endl;
  13.     cout<<"★"<<endl;
  14.     cout<<"▲"<<endl;
  15.     cout<<"●"<<endl;
  16.     cout<<endl;
  17.     cout<<"可用餘額: "<<money<<"元"<<endl<<endl;
  18.     cout<<"(1)買入  (2)下注  (3)離開  請選擇: ";
  19.     cin>>option;
  20.     if(option==1)
  21.     {
  22.         cout<<"買入: ";
  23.         cin>>buy;
  24.         money+=buy;  
  25.         goto re;
  26.     }
  27.     else if(option==2)
  28.     {
  29.         if(money==0)
  30.         {
  31.                     cout<<"你沒錢啦,窮B"<<endl;
  32.                     system("pause");                    
  33.                     goto re;
  34.         }
  35.         int tmp;
  36.         cout<<"下注:";
  37.         cin>> tmp;
  38.         if(tmp>money)   //餘額< 下注金額
  39.         {
  40.            cout<<"到底有沒有錢!傻B!"<<endl;
  41.            system("pause");
  42.            goto re;
  43.         }else if(tmp < money)
  44.         {
  45.              cout<<"(1)◆(2)★(3)▲(4)● 請選擇: "<<endl;
  46.              cin>>option;
  47.         }
  48.     }
  49.     else if(option==3)
  50.     {  
  51.         goto end;
  52.     }else
  53.     {
  54.          cout<<"白癡喔"<<endl;
  55.          system("pause");
  56.          goto re;
  57.     }
  58.     system("pause");
  59.     system("cls");
  60.     srand(time(NULL));
  61.     while(a!=75 && b!=75 && c!=75 && d!=75)
  62.     {
  63.         r=rand()%4;   //產生0~3之隨機亂數
  64.         if(r==0)
  65.             a++;
  66.         else if(r==1)
  67.             b++;
  68.         else if(r==2)
  69.             c++;
  70.         else
  71.             d++;
  72.         cout<<"比賽進行中"<<endl;
  73.         cout<<"------------------------------------------------------------------------| 終點"<<endl;
  74.         for(int i=1; i<=a; i++)
  75.             cout<<" ";
  76.         cout<<"◆"<<endl;
  77.         for(int i=1; i<=b; i++)
  78.             cout<<" ";
  79.         cout<<"★"<<endl;
  80.         for(int i=1; i<=c; i++)
  81.             cout<<" ";
  82.         cout<<"▲"<<endl;
  83.         for(int i=1; i<=d; i++)
  84.             cout<<" ";
  85.         cout<<"●"<<endl;   
  86.         system("cls");      
  87.     }
  88.     cout<<"比賽結束! 由 ";
  89.     if(a==75)
  90.         cout<<"◆";
  91.     else if(b==75)
  92.         cout<<"★";
  93.     else if(c==75)
  94.         cout<<"▲";
  95.     else
  96.         cout<<"●";
  97.     cout<<" 先馳得點!"<<endl;
  98.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  99.     for(int i=1; i<=a; i++)
  100.         cout<<" ";
  101.     cout<<"◆"<<endl;
  102.     for(int i=1; i<=b; i++)
  103.         cout<<" ";
  104.     cout<<"★"<<endl;
  105.     for(int i=1; i<=c; i++)
  106.         cout<<" ";
  107.     cout<<"▲"<<endl;
  108.     for(int i=1; i<=d; i++)
  109.         cout<<" ";
  110.     cout<<"●"<<endl;
  111.     system("pause");
  112.     n++;
  113.     goto re;
  114.      end:
  115.     system("pause");
  116.     return 0;   
  117. }
複製代碼

TOP

返回列表