返回列表 發帖

賽馬程式 (四)

加入首頁選單, 新增買入的功能, 執行畫面如下:


在使用者輸入數值後, 畫面更新如下:


本帖隱藏的內容需要回復才可以瀏覽

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n=1, balance=0;
  8.     int option, buyin;
  9.     re:
  10.     system("cls");
  11.     srand(time(NULL));
  12.     int s[]={0,0,0,0};
  13.     string p[]={"◆","★","▲","●"};
  14.     int r=0;
  15.     cout<<"「好事成雙」賽馬場  第 "<<n<<" 局"<<endl;
  16.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  17.     for(int i=0; i<4; i++)
  18.         cout<<p[i]<<endl;
  19.     cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
  21.     cin>>option;
  22.     if(option==1)
  23.     {
  24.         cout<<"買入: ";
  25.         cin>>buyin;
  26.         balance+=buyin;
  27.         goto re;         
  28.     }
  29.     system("cls");
  30.     while(s[r]<=73)
  31.     {
  32.         r=rand()%4;   //0~3
  33.         s[r]++;
  34.         cout<<"比賽進行中"<<endl;
  35.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  36.         for(int i=0; i<4; i++)
  37.         {
  38.             for(int j=0; j<s[i]; j++)
  39.                 cout<<" ";
  40.             cout<<p[i]<<endl;
  41.         }
  42.         _sleep(50);
  43.         system("cls");
  44.     }
  45.     cout<<"比賽結束!  由 "<<p[r]<<" 先馳得點!"<<endl;
  46.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  47.     for(int i=0; i<4; i++)
  48.     {
  49.         for(int j=0; j<s[i]; j++)
  50.             cout<<" ";
  51.         cout<<p[i]<<endl;
  52.     }
  53.     system("pause");
  54.     n++;
  55.     goto re;
  56.     return 0;
  57. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int m1=0,m2=0;
  8.     int x=1;
  9. re:
  10.     srand(time(NULL));
  11.     int n[]={0,0,0,0};
  12.     cout<<"「好事成雙」賽馬場第"<<x<<"局"<<endl;
  13.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  14.     string y[]={"◆","★","▲","●"};
  15.     cout<<endl<<endl;
  16.     cout<<"可用餘額: "<<m1<<"元"<<endl;
  17.     int option;
  18.     cout<<"(1)買入 (2)下注 (3)離開  請選擇:"<<endl;
  19.     cin>>option;
  20.     if(option==1){
  21.         cout<<"買入:";
  22.         cin>>m2;
  23.         cout<<m2<<"元"<<endl;
  24.         m1+=m2;
  25.     }
  26.     else if(option==2){

  27.     }
  28.     for(int i=0;i<=3;i++)
  29.         cout<<y[i]<<endl;
  30.     int r=0;
  31.     system("pause");
  32.     while(true){
  33.         system("cls");
  34.         r=rand()%4;
  35.         n[r]++;
  36.         cout<<"比賽進行中,第"<<x<<"局"<<endl;
  37.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  38.         for(int i=0;i<=n[0];i++)
  39.             cout<<" ";
  40.             cout<<"◆"<<endl;
  41.         for(int i=0;i<=n[1];i++)
  42.             cout<<" ";
  43.             cout<<"★"<<endl;
  44.         for(int i=0;i<=n[2];i++)
  45.             cout<<" ";
  46.             cout<<"▲"<<endl;
  47.         for(int i=0;i<=n[3];i++)
  48.             cout<<" ";
  49.             cout<<"●"<<endl;
  50.         if(n[r]==73)
  51.             break;

  52.         _sleep(1);

  53.     }system("cls");
  54.     cout<<"比賽結束由"<<y[r]<<"先馳得點!"<<endl;
  55.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  56.         for(int i=0;i<=n[0];i++)
  57.             cout<<" ";
  58.             cout<<"◆"<<endl;
  59.         for(int i=0;i<=n[1];i++)
  60.             cout<<" ";
  61.             cout<<"★"<<endl;
  62.         for(int i=0;i<=n[2];i++)
  63.             cout<<" ";
  64.             cout<<"▲"<<endl;
  65.         for(int i=0;i<=n[3];i++)
  66.             cout<<" ";
  67.             cout<<"●"<<endl;
  68.     system("pause");
  69.     x++;
  70.     system("cls");
  71.     goto re;
  72.     return 0;
  73. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n=1;
  8.     int money=0, x, money2;
  9.     re:
  10.     system("cls");
  11.     srand(time(NULL));
  12.     int s[]={0,0,0,0};
  13.     cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
  14.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  15.     cout<<"◆"<<endl;
  16.     cout<<"★"<<endl;
  17.     cout<<"▲"<<endl;
  18.     cout<<"●"<<endl;
  19.     {
  20.     cout<<"可用餘額:"<<money<<"元"<<endl<<endl;
  21.     cout<<"<1>買入 <2>下注 <3>離開   請選擇:";
  22.     cin>>x;
  23.     if(x==1)
  24.         cout<<"買入: ";
  25.         cin>>money2;
  26.         money+=money2;
  27.     system("cls");
  28.     goto re;
  29.     }
  30.     while(true)
  31.     {
  32.         system("cls");
  33.         int r=rand()%4;
  34.         s[r]++;
  35.         cout<<"比賽進行中"<<endl;
  36.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  37.         for(int i=0; i<=s[0]; i++)
  38.             cout<<" ";
  39.         cout<<"◆"<<endl;
  40.         for(int i=0; i<=s[1]; i++)
  41.             cout<<" ";
  42.         cout<<"★"<<endl;
  43.         for(int i=0; i<=s[2]; i++)
  44.             cout<<" ";
  45.         cout<<"▲"<<endl;
  46.         for(int i=0; i<=s[3]; i++)
  47.             cout<<" ";
  48.         cout<<"●"<<endl;
  49.         if(s[r]==73)
  50.             break;
  51.         _sleep(0.00000001);
  52.     }
  53.     system("cls");
  54.     cout<<"比賽結束 ";
  55.     if(s[0]==73)
  56.         cout<<"由◆先馳得點!"<<endl;
  57.     if(s[1]==73)
  58.         cout<<"由★先馳得點!"<<endl;
  59.     if(s[2]==73)
  60.         cout<<"由▲先馳得點!"<<endl;
  61.     if(s[3]==73)
  62.         cout<<"由●先馳得點!"<<endl;
  63.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  64.     for(int i=0; i<=s[0]; i++)
  65.         cout<<" ";
  66.     cout<<"◆"<<endl;
  67.     for(int i=0; i<=s[1]; i++)
  68.         cout<<" ";
  69.     cout<<"★"<<endl;
  70.     for(int i=0; i<=s[2]; i++)
  71.         cout<<" ";
  72.     cout<<"▲"<<endl;
  73.     for(int i=0; i<=s[3]; i++)
  74.         cout<<" ";
  75.     cout<<"●"<<endl;
  76.     system("pause");
  77.     n++;
  78.     goto re;
  79.     return 0;
  80. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int t=1;
  8.     int s,sum,v,money=0;
  9.     re1:
  10.     srand(time(NULL));
  11.     cout<<"賽馬場   第"<<t<<"局"<<endl;
  12.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  13.     int a[]{0,0,0,0};

  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     re2:
  19.     cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
  20.     cout<<"(1)買入 (2)下注 (3)離開   請選擇:";
  21.     cin>>v;
  22.     if(v==1)
  23.     {
  24.         cout<<"買入: ";
  25.         cin>>money;
  26.         sum+=money;


  27.     }
  28.     system("pause");
  29.     cout<<"比賽開始"<<endl;
  30.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;

  31.     re:
  32.     if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73){
  33.         system("cls");
  34.         cout<<"比賽進行中"<<endl;
  35.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;


  36.         s=rand()%4;
  37.         a[s]++;

  38.         for(int i=1; i<=a[0]; i++)
  39.                 cout<<" ";
  40.             cout<<"◆"<<endl;
  41.         for(int i=1; i<=a[1]; i++)
  42.                 cout<<" ";
  43.             cout<<"★"<<endl;
  44.         for(int i=1; i<=a[2]; i++)
  45.                 cout<<" ";
  46.             cout<<"▲"<<endl;
  47.         for(int i=1; i<=a[3]; i++)
  48.                 cout<<" ";
  49.             cout<<"●"<<endl;
  50.          _sleep(1);


  51.         goto re;
  52.         }else{
  53.         system("cls");
  54.         if(a[0]>=73){

  55.             cout<<"比賽結束,最終由◆勝出!!!"<<endl;

  56.         }else if(a[1]>=73){

  57.             cout<<"比賽結束,最終由★勝出!!!"<<endl;

  58.         }else if(a[2]>=73){

  59.             cout<<"比賽結束,最終由▲勝出!!!"<<endl;

  60.         }else if(a[3]>=73){

  61.             cout<<"比賽結束,最終由●勝出!!!"<<endl;

  62.         }

  63.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  64.         }
  65.         for(int i=1; i<=a[0]; i++)
  66.                 cout<<" ";
  67.             cout<<"◆"<<endl;
  68.            for(int i=1; i<=a[1]; i++)
  69.                 cout<<" ";
  70.             cout<<"★"<<endl;
  71.            for(int i=1; i<=a[2]; i++)
  72.                 cout<<" ";
  73.             cout<<"▲"<<endl;
  74.            for(int i=1; i<=a[3]; i++)
  75.                 cout<<" ";
  76.             cout<<"●"<<endl;
  77.         t++;
  78.         system("pause");
  79.         goto re1;
  80.         return 0;
  81.     }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int n=1,money=0;
  8.     re:
  9.     system("cls");
  10.     int a=0, b=0, c=0, d=0,sum,choose;
  11.     srand(time(NULL));
  12.     cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
  13.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<"可用餘額:"<<money<<endl;
  19.     cout<<"(1)買入  (2)下注  (3)離開"<<endl;
  20.     cin>>choose;
  21.     if(choose==1){
  22.         cout<<"金額"<<endl;
  23.         cin>>sum;
  24.         money+=sum;
  25.         goto re;
  26.     }

  27.     system("pause");


  28.     while(true){
  29.     system("cls");
  30.     cout<<"比賽中"<<endl;
  31.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;\


  32.     int r=rand()%4;
  33.     if(r==0){
  34.         a++;
  35.     }
  36.     else if(r==1){
  37.         b++;
  38.     }
  39.     else if(r==2){
  40.         c++;
  41.     }
  42.     else if(r==3){
  43.         d++;
  44.     }

  45.     for(int i=1; i<=a; i++){
  46.         cout<<" ";}
  47.     cout<<"◆"<<endl;

  48.     for(int j=1; j<=b; j++){
  49.         cout<<" ";}
  50.     cout<<"★"<<endl;

  51.     for(int k=1; k<=c; k++){
  52.         cout<<" ";}
  53.     cout<<"▲"<<endl;

  54.     for(int l=1; l<=d; l++){
  55.         cout<<" ";}
  56.     cout<<"●"<<endl;
  57.     _sleep(50);
  58.     if((a==73)||(b==73)||(c==73)||(d==73))
  59.         break;
  60.     }
  61.     system("cls");
  62.     if(a==73){
  63.     cout<<"比賽結束,由◆先馳得點"<<endl;
  64.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  65.     }
  66.     if(b==73){
  67.     cout<<"比賽結束,由★先馳得點"<<endl;
  68.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  69.     }
  70.     if(c==73){
  71.     cout<<"比賽結束,由▲先馳得點"<<endl;
  72.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  73.     }
  74.     if(d==73){
  75.     cout<<"比賽結束,由●先馳得點"<<endl;
  76.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  77.     }
  78.     for(int i=1; i<=a; i++){
  79.         cout<<" ";}
  80.     cout<<"◆"<<endl;

  81.     for(int j=1; j<=b; j++){
  82.         cout<<" ";}
  83.     cout<<"★"<<endl;

  84.     for(int k=1; k<=c; k++){
  85.         cout<<" ";}
  86.     cout<<"▲"<<endl;

  87.     for(int l=1; l<=d; l++){
  88.         cout<<" ";}
  89.     cout<<"●"<<endl;
  90.     n++;
  91.     system("pause");
  92.     goto re;
  93.     return 0;
  94. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     int x,y,z,sum=0,money,money2;
  8.     int a[]{0,0,0,0};
  9.     string b[]{"◆","★","▲","●"};
  10.     re2:
  11.     system("cls");
  12.     cout<<"空蕩蕩賽馬場"<<endl;
  13.     cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  14.     cout<<"◆"<<endl;
  15.     cout<<"★"<<endl;
  16.     cout<<"▲"<<endl;
  17.     cout<<"●"<<endl;
  18.     cout<<endl;
  19.     cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
  20.     cout<<"<1>買入 <2>下注 <3>離開   請選擇:";
  21.     cin>>z;
  22.     if(z==1)
  23.     {
  24.         cout<<"買入: ";
  25.         cin>>money;
  26.         sum+=money;
  27.         goto re2;
  28.     }
  29.     system("pause");
  30.     re:
  31.     if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
  32.     {
  33.         system("cls");
  34.         cout<<"比賽開始"<<endl;
  35.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  36.         for(int i=0; i<=3; i++)
  37.        {
  38.            x=rand()%5+1;
  39.            a[i]+=x;
  40.            }
  41.            for(int i=1; i<=a[0]; i++)
  42.                 cout<<" ";
  43.             cout<<"◆"<<endl;
  44.            for(int i=1; i<=a[1]; i++)
  45.                 cout<<" ";
  46.             cout<<"★"<<endl;
  47.            for(int i=1; i<=a[2]; i++)
  48.                 cout<<" ";
  49.             cout<<"▲"<<endl;
  50.            for(int i=1; i<=a[3]; i++)
  51.                 cout<<" ";
  52.             cout<<"●"<<endl;
  53.          _sleep(100);
  54.         goto re;

  55.     }
  56.     else
  57.     {
  58.         if(a[0]>=73)
  59.             y=0;
  60.         if(a[1]>=73)
  61.             y=1;
  62.         if(a[2]>=73)
  63.             y=2;
  64.         if(a[3]>=73)
  65.             y=3;
  66.         system("cls");
  67.         cout<<"比賽結束由"<<b[y]<<"獲勝"<<endl;
  68.         cout<<"-------------------------------------------------------------------------| 終點"<<endl;
  69.            for(int i=1; i<=a[0]; i++)
  70.                 cout<<" ";
  71.             cout<<"◆"<<endl;
  72.            for(int i=1; i<=a[1]; i++)
  73.                 cout<<" ";
  74.             cout<<"★"<<endl;
  75.            for(int i=1; i<=a[2]; i++)
  76.                 cout<<" ";
  77.             cout<<"▲"<<endl;
  78.            for(int i=1; i<=a[3]; i++)
  79.                 cout<<" ";
  80.             cout<<"●"<<endl;
  81.     }
  82.     system("pause");
  83.     return 0;
  84. }
複製代碼

TOP

返回列表