返回列表 發帖
  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,bet,horse;
  11.     cout<<"日本東京競馬場<東京優駿>[2400m草地]"<<endl;
  12.     cout<< "----------------------------------------------------------------------|goal"<<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.     if(option==1)
  23.     {
  24.                  cout<<"買入:";
  25.                  cin>>buyin;
  26.                  blance += buyin;
  27.                  goto re;
  28.     } else if(option==2)
  29.     {
  30.            cout<<"請下注:";
  31.            cin>>bet;
  32.            if(bet > blance)
  33.            {
  34.                   cout<<"您餘額不足,請重新下注!"<<endl;        
  35.            }else if(bet >0 && bet<=blance)
  36.            {
  37.                  cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
  38.                  cin>>horse;
  39.                  blance == bet;
  40.            }else
  41.             {
  42.            cout<<"您輸入錯誤,請重新下注!"<<endl;
  43.         }
  44.         system("pause");
  45.         goto re;
  46.     }else
  47.     {
  48.     }
  49.     system("pause");
  50.     system("cls");
  51.     srand(time(NULL));
  52.     string words ="賽馬進行中";
  53.     string name[4] = {"◆","★","▲","●"};
  54.     int position =0;
  55.     while(a<=70 && b<=70 && c<=70 && d<=70)
  56.     {  
  57.       cout<<words<<endl;
  58.       cout<<"------------------------------------------------------------------------| 終點"<<endl;
  59.       r = rand()%4+1;
  60.       switch(r)
  61.       {
  62.           case 1:
  63.                a++;
  64.                break;
  65.           case 2:
  66.                b++;
  67.                break;
  68.           case 3:
  69.                c++;
  70.                break;
  71.           case 4:
  72.                d++;
  73.                break;
  74.       }
  75.       for(int i=0;i<=a;i++)
  76.       {
  77.           cout<<" ";
  78.       }
  79.       cout<<name[0]<<endl;
  80.       for(int i=0;i<=b;i++)
  81.       {
  82.           cout<<" ";
  83.       }
  84.       cout<<name[1]<<endl;
  85.       for(int i=0;i<=c;i++)
  86.       {
  87.           cout<<" ";
  88.       }
  89.       cout<<name[2]<<endl;
  90.       for(int i=0;i<=d;i++)
  91.       {
  92.           cout<<" ";
  93.       }
  94.       cout<<name[3]<<endl;
  95.       if(a==70 || b==70 || c==70 || d==70)
  96.       {
  97.          if(a==70)
  98.                   position = 0;
  99.          if(b==70)
  100.                   position = 1;
  101.          if(c==70)
  102.                   position = 2;
  103.          if(d==70)
  104.                   position = 3;
  105.          words = "比賽結束!由"+name[position]+"先馳得點!";
  106.       }
  107.       if(a==71 || b==71 || c==71 || d==71)
  108.       {      
  109.       }else{      
  110.         system("cls");
  111.       }
  112.     }
  113.     n++;
  114.     system("pause");
  115.     goto re;
  116.     return 0;   
  117. }
複製代碼

TOP

返回列表