返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,balance=0; //第n局
  7.     re:
  8.     int a=0,b=0,c=0,d=0,r,option,buyin; //r為亂數選出的馬,x為贏的馬
  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<<"可用餘額:"<<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 re;
  26.     }
  27.     system("pause");
  28.     system("cls");
  29.     srand(time(NULL));
  30.     while(a!=70 && b!=70 && c!=70 && d!=70)
  31.     {
  32.         cout<<"~賽馬進行中~"<<"第"<<n<<"局"<<endl;
  33.         cout<<"|起點|--------------------------------------------------------------|終點|"<<endl;        
  34.         r=rand()%4;
  35.         if(r==0)
  36.         {
  37.             a++;
  38.         }
  39.         if(r==1)
  40.         {
  41.             b++;
  42.         }
  43.         if(r==2)
  44.         {
  45.             c++;
  46.         }
  47.         if(r==3)
  48.         {
  49.             d++;
  50.         }
  51.         for(int i=0;i<=a;i++)
  52.         {
  53.             cout<<" ";
  54.         }
  55.             cout<<"★"<<endl;
  56.         for(int i=0;i<=b;i++)
  57.         {
  58.             cout<<" ";
  59.         }
  60.             cout<<"㊣"<<endl;
  61.         for(int i=0;i<=c;i++)
  62.         {
  63.             cout<<" ";
  64.         }
  65.             cout<<"▽"<<endl;
  66.         for(int i=0;i<=d;i++)
  67.         {
  68.             cout<<" ";
  69.         }
  70.             cout<<"◆"<<endl;
  71.         system("cls");
  72.     }
  73.    
  74.     if(a==70)
  75.     {
  76.         cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由★先馳得點!"<<endl;
  77.     }
  78.     else if(b==70)
  79.     {
  80.         cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由㊣先馳得點!"<<endl;
  81.     }
  82.     else if(c==70)
  83.     {
  84.         cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由▽先馳得點!"<<endl;
  85.     }
  86.     else
  87.     {
  88.         cout<<"~比賽結束~"<<"第"<<n<<"局"<<"由◆先馳得點!"<<endl;
  89.     }
  90.    
  91.     cout<<"|起點|--------------------------------------------------------------|終點|"<<endl;
  92.     for(int i=0;i<=a;i++)
  93.         {
  94.             cout<<" ";
  95.         }
  96.             cout<<"★"<<endl;
  97.         for(int i=0;i<=b;i++)
  98.         {
  99.             cout<<" ";
  100.         }
  101.             cout<<"㊣"<<endl;
  102.         for(int i=0;i<=c;i++)
  103.         {
  104.             cout<<" ";
  105.         }
  106.             cout<<"▽"<<endl;
  107.         for(int i=0;i<=d;i++)
  108.         {
  109.             cout<<" ";
  110.         }
  111.             cout<<"◆"<<endl;
  112.         system("pause");
  113.         system("cls");
  114.         n++;
  115.         goto re;
  116.     system("pause");
  117.     return 0;
  118. }
複製代碼

TOP

返回列表