返回列表 發帖
  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.   
  25.     if(option==1)
  26.     {
  27.         cout<<"買入:";
  28.         cin>>buyin;
  29.         blance += buyin;
  30.         goto re;
  31.     }
  32.    
  33.     system("pause");
  34.     system("cls");
  35.     srand(time(NULL));

  36.    
  37.     string words ="賽馬進行中";
  38.    
  39.     string name[4] = {"◆","★","▲","●"};
  40.    
  41.    
  42.     int position =0;
  43.     while(a<=70 && b<=70 && c<=70 && d<=70)
  44.     {  
  45.       cout<<words<<endl;
  46.       cout<<"------------------------------------------------------------------------| 終點"<<endl;   

  47.       r = rand()%4+1;

  48.       switch(r)
  49.       {
  50.           case 1:
  51.                a++;
  52.                break;
  53.           case 2:
  54.                b++;
  55.                break;
  56.           case 3:
  57.                c++;
  58.                break;
  59.           case 4:
  60.                d++;
  61.                break;
  62.       }
  63.       
  64.   
  65.       for(int i=0;i<=a;i++)
  66.       {
  67.           cout<<" ";
  68.       }
  69.       cout<<name[0]<<endl;
  70.       
  71.    
  72.       for(int i=0;i<=b;i++)
  73.       {
  74.           cout<<" ";
  75.       }
  76.       cout<<name[1]<<endl;
  77.       

  78.       for(int i=0;i<=c;i++)
  79.       {
  80.           cout<<" ";
  81.       }
  82.       cout<<name[2]<<endl;
  83.       

  84.       for(int i=0;i<=d;i++)
  85.       {
  86.           cout<<" ";
  87.       }
  88.       cout<<name[3]<<endl;
  89.       
  90.    
  91.       if(a==70 || b==70 || c==70 || d==70)
  92.       {  
  93.          if(a==70)
  94.               position = 0;
  95.          if(b==70)
  96.               position =1;
  97.          if(c==70)
  98.               position =2;
  99.          if(d==70)
  100.               position =3;           
  101.          
  102.          words = "比賽結束!由"+name[position]+"先馳得點!";
  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

返回列表