返回列表 發帖
  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.    
  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.     if(option==1)
  24.     {
  25.         cout<<"買入:";
  26.         cin>>buyin;
  27.         blance += buyin;
  28.         goto re;
  29.     }
  30.     system("pause");
  31.     system("cls");
  32.     srand(time(NULL));
  33.     string words ="賽馬進行中";
  34.     string name[4] = {"◆","★","▲","●"};
  35.     int position =0;
  36.     while(a<=70 && b<=70 && c<=70 && d<=70)
  37.     {  
  38.       cout<<words<<endl;
  39.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  40.       r = rand()%4+1;
  41.       switch(r)
  42.       {
  43.           case 1:
  44.                a++;
  45.                break;
  46.           case 2:
  47.                b++;
  48.                break;
  49.           case 3:
  50.                c++;
  51.                break;
  52.           case 4:
  53.                d++;
  54.                break;
  55.       }   
  56.       for(int i=0;i<=a;i++)
  57.       {
  58.           cout<<" ";
  59.       }
  60.       cout<<name[0]<<endl;
  61.       for(int i=0;i<=b;i++)
  62.       {
  63.           cout<<" ";
  64.       }
  65.       cout<<name[1]<<endl;
  66.       for(int i=0;i<=c;i++)
  67.       {
  68.           cout<<" ";
  69.       }
  70.       cout<<name[2]<<endl;
  71.       for(int i=0;i<=d;i++)
  72.       {
  73.           cout<<" ";
  74.       }
  75.       cout<<name[3]<<endl;
  76.       
  77.    
  78.       if(a==70 || b==70 || c==70 || d==70)
  79.       {  
  80.          if(a==70)
  81.               position = 0;
  82.          if(b==70)
  83.               position =1;
  84.          if(c==70)
  85.               position =2;
  86.          if(d==70)
  87.               position =3;           
  88.          
  89.          words = "比賽結束!由"+name[position]+"先馳得點!";
  90.       }
  91.       if(a==71 || b==71 || c==71 || d==71)
  92.       {               
  93.       }else{      
  94.         system("cls");
  95.       }
  96.     }
  97.     n++;
  98.     system("pause");
  99.     system("cls");
  100.     goto re;
  101.     return 0;   
  102. }
複製代碼

TOP

返回列表