返回列表 發帖
  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.    
  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.     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.       for(int i=0;i<=a;i++)
  59.       {
  60.           cout<<" ";
  61.       }
  62.       cout<<name[0]<<endl;
  63.       for(int i=0;i<=b;i++)
  64.       {
  65.           cout<<" ";
  66.       }
  67.       cout<<name[1]<<endl;
  68.       for(int i=0;i<=c;i++)
  69.       {
  70.           cout<<" ";
  71.       }
  72.       cout<<name[2]<<endl;
  73.       for(int i=0;i<=d;i++)
  74.       {
  75.           cout<<" ";
  76.       }
  77.       cout<<name[3]<<endl;
  78.       
  79.    
  80.       if(a==70 || b==70 || c==70 || d==70)
  81.       {  
  82.          if(a==70)
  83.               position = 0;
  84.          if(b==70)
  85.               position =1;
  86.          if(c==70)
  87.               position =2;
  88.          if(d==70)
  89.               position =3;           
  90.          
  91.          words = "比賽結束!由"+name[position]+"先馳得點!";
  92.       }
  93.       if(a==71 || b==71 || c==71 || d==71)
  94.       {               
  95.       }else{      
  96.         system("cls");
  97.       }
  98.       
  99.     }
  100.     n++;
  101.     system("pause");
  102.     goto re;
  103.     return 0;   
  104. }
複製代碼

TOP

返回列表