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

TOP

返回列表