返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n =1,blance=0;
  8.     re:
  9.     system("cls");
  10.     int a=0,b=0,c=0,d=0,r, option, buyin =0 ;  
  11.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  12.     cout<<"------------------------------------------------------------------------| 終點"<<endl;
  13.     cout<<"◆"<<endl;
  14.     cout<<"★"<<endl;
  15.     cout<<"▲"<<endl;
  16.     cout<<"●"<<endl;
  17.     cout<<endl;
  18.     cout<<"可用餘額:"<<blance<<"元"<<endl;
  19.     cout<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
  21.     cin>>option;
  22.    
  23.     if(option==1)
  24.     {
  25.         cout<<"買入:";
  26.         cin>>buyin;
  27.         blance += buyin;
  28.         goto re;
  29.     }
  30.    
  31.     system("pause");
  32.     system("cls");
  33.     srand(time(NULL));
  34.     string words ="賽馬進行中";
  35.     string name[4] = {"◆","★","▲","●"};
  36.    
  37.     int position =0;
  38.     while(a<=70 && b<=70 && c<=70 && d<=70)
  39.     {  
  40.       cout<<words<<endl;
  41.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   
  42.       r = rand()%4+1;
  43.       switch(r)
  44.       {
  45.           case 1:
  46.                a++;
  47.                break;
  48.           case 2:
  49.                b++;
  50.                break;
  51.           case 3:
  52.                c++;
  53.                break;
  54.           case 4:
  55.                d++;
  56.                break;
  57.       }
  58.       
  59.       for(int i=0;i<=a;i++)
  60.       {
  61.           cout<<" ";
  62.       }
  63.       cout<<name[0]<<endl;
  64.       
  65.       for(int i=0;i<=b;i++)
  66.       {
  67.           cout<<" ";
  68.       }
  69.       cout<<name[1]<<endl;
  70.       
  71.       for(int i=0;i<=c;i++)
  72.       {
  73.           cout<<" ";
  74.       }
  75.       cout<<name[2]<<endl;
  76.       
  77.       for(int i=0;i<=d;i++)
  78.       {
  79.           cout<<" ";
  80.       }
  81.       cout<<name[3]<<endl;
  82.       
  83.    
  84.       if(a==70 || b==70 || c==70 || d==70)
  85.       {  
  86.          if(a==70)
  87.               position = 0;
  88.          if(b==70)
  89.               position =1;
  90.          if(c==70)
  91.               position =2;
  92.          if(d==70)
  93.               position =3;           
  94.          
  95.          words = "比賽結束!由"+name[position]+"先馳得點!";
  96.       }
  97.       if(a==71 || b==71 || c==71 || d==71)
  98.       {               
  99.       }else{      
  100.         system("cls");
  101.       }
  102.       
  103.     }

  104.     n++;
  105.     system("pause");
  106.     goto re;
  107.     return 0;   
  108. }
複製代碼

TOP

返回列表