返回列表 發帖
本帖最後由 曾善勤 於 2022-3-26 11:26 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.   
  8.     int n =1,blance=0;
  9.     re:
  10.       system("cls");
  11.     int a=0,b=0,c=0,d=0,r, option, buyin =0 ;
  12.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  13.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<endl;
  19.     cout<<"可用餘額:"<<blance<<"元"<<endl;
  20.     cout<<endl;
  21.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  22.     cin>>option;
  23.    

  24.     if(option==1)
  25.     {
  26.         cout<<"買入:";
  27.         cin>>buyin;
  28.         blance += buyin;
  29.         goto re;
  30.     }
  31.    
  32.     system("pause");
  33.     system("cls");
  34.     srand(time(NULL));


  35.     string words ="賽馬進行中";

  36.     string name[4] = {"◆","★","▲","●"};
  37.    

  38.     int position =0;
  39.     while(a<=70 && b<=70 && c<=70 && d<=70)
  40.     {  
  41.       cout<<words<<endl;
  42.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  43.    
  44.       r = rand()%4+1;
  45.      
  46.       switch(r)
  47.       {
  48.           case 1:
  49.                a++;
  50.                break;
  51.           case 2:
  52.                b++;
  53.                break;
  54.           case 3:
  55.                c++;
  56.                break;
  57.           case 4:
  58.                d++;
  59.                break;
  60.       }
  61.       
  62.      
  63.       for(int i=0;i<=a;i++)
  64.       {
  65.           cout<<" ";
  66.       }
  67.       cout<<name[0]<<endl;
  68.       
  69.       
  70.       for(int i=0;i<=b;i++)
  71.       {
  72.           cout<<" ";
  73.       }
  74.       cout<<name[1]<<endl;
  75.       
  76.       for(int i=0;i<=c;i++)
  77.       {
  78.           cout<<" ";
  79.       }
  80.       cout<<name[2]<<endl;
  81.       
  82.      
  83.       for(int i=0;i<=d;i++)
  84.       {
  85.           cout<<" ";
  86.       }
  87.       cout<<name[3]<<endl;
  88.       
  89.    
  90.       if(a==70 || b==70 || c==70 || d==70)
  91.       {  
  92.          if(a==70)
  93.               position = 0;
  94.          if(b==70)
  95.               position =1;
  96.          if(c==70)
  97.               position =2;
  98.          if(d==70)
  99.               position =3;           
  100.          
  101.          words = "比賽結束!由"+name[position]+"先馳得點!";
  102.       }
  103.    
  104.       if(a==71 || b==71 || c==71 || d==71)
  105.       {               
  106.       }else{      
  107.         system("cls");
  108.       }
  109.       
  110.     }

  111.     n++;
  112.     system("pause");

  113.     goto re;
  114.     return 0;   
  115. }
複製代碼

TOP

返回列表