返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,mon=0,in,choose,out=0,peo;
  7.     re:
  8.     int a=0,b=0,c=0,d=0,h;
  9.     cout<<"「好事成雙」賽馬場"<<"第"<<n<<"場"<<endl;
  10.     cout<<"|--------------------------------------------------|"<<endl;
  11.     cout<<"◆"<<endl;
  12.     cout<<"★"<<endl;
  13.     cout<<"▲"<<endl;
  14.     cout<<"●"<<endl;
  15.     cout<<"可用餘額為"<<mon<<endl;
  16.     cout<<"1.買入\t2.下注\t3.離開"<<endl;
  17.     cin>>choose;
  18.    
  19.     if(choose==1)
  20.     {   system("cls");         
  21.      cout<<"請輸入買入金額:";
  22.      cin>>in ;      
  23.      mon+=in;
  24.      goto re;     
  25.     }
  26.     else if(choose==2)
  27.     { system("cls");
  28.      cout<<"請輸入下注金額:";
  29.      cin>>out;
  30.      if(mon>=out && out>=1)
  31.      {
  32.       cout<<"下注對象\ta:◆\tb:★\tc:▲\td:●:";
  33.       cin>>peo;           
  34.       mon-=out;
  35.       goto start;
  36.      }else
  37.      {cout<<"錯誤";
  38.       goto re;
  39.      }
  40.     }else
  41.      { system("cls");
  42.           goto end;
  43.      }
  44.    
  45.     srand(time(NULL));
  46.    start:
  47.     system("pause");
  48.     system("cls");
  49.     while(a!=50 && b!=50 && c!=50 && d!=50)
  50.     {
  51.           cout<<"賽馬進行中"<<endl;
  52.           cout<<"|--------------------------------------------------|"<<endl;
  53.           h = rand()%4+1;
  54.           if(h==1)
  55.              a++;
  56.           if(h==2)
  57.              b++;
  58.           if(h==3)
  59.              c++;
  60.           if(h==4)
  61.              d++;
  62.             
  63.           for(int i=0;i<=a;i++)
  64.           {
  65.                   cout<<" ";
  66.           }
  67.           cout<<"◆"<<endl;
  68.           for(int i=0;i<=b;i++)
  69.           {
  70.                   cout<<" ";
  71.           }
  72.           cout<<"★"<<endl;
  73.           for(int i=0;i<=c;i++)
  74.           {
  75.                   cout<<" ";
  76.           }
  77.           cout<<"▲"<<endl;
  78.           for(int i=0;i<=d;i++)
  79.           {
  80.                   cout<<" ";
  81.           }
  82.           cout<<"●"<<endl;
  83.           system("cls");
  84.     }
  85.     cout<<"比賽結束\t";
  86.     if(a==50)
  87.     cout<<"由◆拿下勝利"<<endl;
  88.      if(b==50)
  89.     cout<<"由★拿下勝利"<<endl;
  90.      if(c==50)
  91.     cout<<"由▲拿下勝利"<<endl;
  92.      if(d==50)
  93.     cout<<"由●拿下勝利"<<endl;
  94.    
  95.     cout<<"|--------------------------------------------------|"<<endl;
  96.     for(int i=0;i<=a;i++)
  97.     {
  98.         cout<<" ";
  99.     }
  100.     cout<<"◆"<<endl;
  101.     for(int i=0;i<=b;i++)
  102.     {
  103.         cout<<" ";
  104.     }
  105.     cout<<"★"<<endl;
  106.     for(int i=0;i<=c;i++)
  107.     {
  108.         cout<<" ";
  109.     }
  110.     cout<<"▲"<<endl;
  111.     for(int i=0;i<=d;i++)
  112.     {     
  113.         cout<<" ";
  114.     }
  115.     cout<<"●"<<endl;
  116.     system("pause");
  117.     system("cls");
  118.     n++;
  119.     goto re;
  120.     end:
  121.     system("pause");
  122.     return 0;
  123. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n=1,mon=0,in,choose,out=0,peo;
  7.     re:
  8.     int a=0,b=0,c=0,d=0,h;
  9.     cout<<"「好事成雙」賽馬場"<<"第"<<n<<"場"<<endl;
  10.     cout<<"|--------------------------------------------------|"<<endl;
  11.     cout<<"◆"<<endl;
  12.     cout<<"★"<<endl;
  13.     cout<<"▲"<<endl;
  14.     cout<<"●"<<endl;
  15.     cout<<"可用餘額為"<<mon<<endl;
  16.     cout<<"1.買入\t2.下注\t3.離開"<<endl;
  17.     cin>>choose;
  18.    
  19.     if(choose==1)
  20.     {   system("cls");         
  21.      cout<<"請輸入買入金額:";
  22.      cin>>in ;      
  23.      mon+=in;
  24.      goto re;     
  25.     }
  26.     else if(choose==2)
  27.     { system("cls");
  28.      cout<<"請輸入下注金額:";
  29.      cin>>out;
  30.      if(mon>=out && out>=1)
  31.      {
  32.       cout<<"下注對象\ta:◆\tb:★\tc:▲\td:●:";
  33.       cin>>peo;           
  34.       mon-=out;
  35.       goto start;
  36.      }else
  37.      {cout<<"錯誤";
  38.       goto re;
  39.      }
  40.     }else
  41.      { system("cls");
  42.           goto end;
  43.      }
  44.    
  45.     srand(time(NULL));
  46.    start:
  47.     system("pause");
  48.     system("cls");
  49.     while(a!=50 && b!=50 && c!=50 && d!=50)
  50.     {
  51.           cout<<"賽馬進行中"<<endl;
  52.           cout<<"|--------------------------------------------------|"<<endl;
  53.           h = rand()%4+1;
  54.           if(h==1)
  55.              a++;
  56.           if(h==2)
  57.              b++;
  58.           if(h==3)
  59.              c++;
  60.           if(h==4)
  61.              d++;
  62.             
  63.           for(int i=0;i<=a;i++)
  64.           {
  65.                   cout<<" ";
  66.           }
  67.           cout<<"◆"<<endl;
  68.           for(int i=0;i<=b;i++)
  69.           {
  70.                   cout<<" ";
  71.           }
  72.           cout<<"★"<<endl;
  73.           for(int i=0;i<=c;i++)
  74.           {
  75.                   cout<<" ";
  76.           }
  77.           cout<<"▲"<<endl;
  78.           for(int i=0;i<=d;i++)
  79.           {
  80.                   cout<<" ";
  81.           }
  82.           cout<<"●"<<endl;
  83.           system("cls");
  84.     }
  85.     cout<<"比賽結束\t";
  86.     if(a==50)
  87.     {cout<<"由◆拿下勝利";
  88.     if(peo==a)
  89.     {
  90.      cout<<"贏得"<<out*3<<endl;         
  91.      mon+=out*3;
  92.     }else
  93.     {cout<<"損失"<<out<<endl;
  94.     }
  95.     }
  96.     else if(b==50)
  97.     {cout<<"由★拿下勝利";
  98.      if(peo==a)
  99.     {
  100.      cout<<"贏得"<<out*3<<endl;         
  101.      mon+=out*3;
  102.     }else
  103.     {cout<<"損失"<<out<<endl;
  104.     }
  105.    
  106.     }
  107.     else if(c==50)
  108.     {cout<<"由▲拿下勝利";
  109.      if(peo==a)
  110.     {
  111.      cout<<"贏得"<<out*3<<endl;         
  112.      mon+=out*3;
  113.     }else
  114.     {cout<<"損失"<<out<<endl;
  115.     }
  116.    
  117.     }
  118.     else
  119.     {cout<<"由●拿下勝利";
  120.     if(peo==a)
  121.     {
  122.      cout<<"贏得"<<out*3<<endl;         
  123.      mon+=out*3;
  124.     }else
  125.     {cout<<"損失"<<out<<endl;
  126.     }
  127.    
  128.     }
  129.    
  130.     cout<<"|--------------------------------------------------|"<<endl;
  131.     for(int i=0;i<=a;i++)
  132.     {
  133.         cout<<" ";
  134.     }
  135.     cout<<"◆"<<endl;
  136.     for(int i=0;i<=b;i++)
  137.     {
  138.         cout<<" ";
  139.     }
  140.     cout<<"★"<<endl;
  141.     for(int i=0;i<=c;i++)
  142.     {
  143.         cout<<" ";
  144.     }
  145.     cout<<"▲"<<endl;
  146.     for(int i=0;i<=d;i++)
  147.     {     
  148.         cout<<" ";
  149.     }
  150.     cout<<"●"<<endl;
  151.     system("pause");
  152.     system("cls");
  153.     n++;
  154.     goto re;
  155.     end:
  156.     system("pause");
  157.     return 0;
  158. }
複製代碼

TOP

返回列表