標題:
賽馬程式 (四)
[打印本頁]
作者:
tonyh
時間:
2014-4-19 16:39
標題:
賽馬程式 (四)
本帖最後由 tonyh 於 2014-4-19 16:49 編輯
加入首頁選單, 新增買入的功能, 執行畫面如下:
可用餘額: 0 元
(1)買入 (2)下注 (3)離開 請選擇: 1
買入: 200
在使用者輸入數值後, 畫面更新如下:
可用餘額: 200 元
(1)買入 (2)下注 (3)離開 請選擇:
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0;
re1:
int a=0, b=0, c=0, d=0, r, option, buyin;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin; //balance=balance+buyin
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4; //產生0~3之隨機亂數
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2014-4-19 16:53
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, balance=0;
re:
int a=0, b=0, c=0, d=0, r , option, buyin=0;
system("cls");
cout<<"「穩賺不賠」賽馬場 <第"<<n<<"場>"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"★1☆"<<endl;
cout<<"☆2★"<<endl;
cout<<"★3☆"<<endl;
cout<<"☆4★"<<endl<<endl;
cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance=balance+buyin;
goto re;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && b!=70)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中..."<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"★1☆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"☆2★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"★3☆"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆4★"<<endl;
system("cls");
}
if(a>b && a>c && a>d)
cout<<"比賽結束,由1號選手先馳得點"<<endl;
if(b>a && b>c && b>d)
cout<<"比賽結束,由2號選手先馳得點"<<endl;
if(c>a && c>b && c>d)
cout<<"比賽結束,由3號選手先馳得點"<<endl;
if(d>a && d>b && d>c)
cout<<"比賽結束,由4號選手先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"★1☆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"☆2★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"★3☆"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆4★"<<endl;
system("pause");
n++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2014-4-19 16:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int e=1,balance=0;
re1:
int a=0,b=0,c=0,d=0,r,option,buyin;
system("cls");
cout<<"$ 888賽馬場 第"<<e<<"局 $"<<endl;
cout<<"--------------------------------------------------------------------------│"<<endl;
cout<<"◢1◤"<<endl;
cout<<"◢2◤"<<endl;
cout<<"◢3◤"<<endl;
cout<<"◢4◤"<<endl;
cout<<endl;
cout<<"可用餘額:"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------│終點"<<endl;
for(int i=1;i<=a;i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1;i<=b;i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1;i<=c;i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1;i<=d;i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("cls");
}
cout<<"比賽結束!由 ";
if(a==75)
cout<<"◢1◤";
if(b==75)
cout<<"◢2◤";
if(c==75)
cout<<"◢3◤";
if(d==75)
cout<<"◢4◤";
cout<<" 先馳得點"<<endl;
cout<<"--------------------------------------------------------------------------│終點"<<endl;
for(int i=1;i<=a;i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1;i<=b;i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1;i<=c;i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1;i<=d;i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("pause");
e++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2014-4-19 16:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int e=1,balance=0;
re1:
int a=0, b=0, c=0, d=0, r, option, buyin;
system("cls");
cout<<"gg賽馬場 第 "<<e<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 獲勝!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
e++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2014-4-19 16:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int t=1, j=0;
re1:
int a=0, b=0, c=0, d=0, r, k, m;
system("cls");
cout<<"﹩財源滾滾賽馬場 ﹩";
cout<<" 第"<<t<<"局"<<endl;
cout<<"=========================================================================| 終點"<<endl;
cout<<"◢1◤"<<endl;
cout<<"◢2◤"<<endl;
cout<<"◢3◤"<<endl;
cout<<"◢4◤"<<endl;
cout<<"可用餘額"<<j<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>k;
if(k==1)
{
cout<<"買入: ";
cin>>m;
j+=m;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"=========================================================================| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("cls");
}
cout<<"比賽結束";
if(a==75)
cout<<" 由◢1◤獲得勝利"<<endl;
else if(b==75)
cout<<" 由◢2◤獲得勝利"<<endl;
else if(c==75)
cout<<" 由◢3◤獲得勝利"<<endl;
else
cout<<" 由◢4◤獲得勝利"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("pause");
t++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2014-4-19 16:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0;
re1:
int a=0,b=0,c=0,d=0,r,option,buyin;
system("cls");
cout<<"天觀馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2014-4-19 16:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0;
re1:
int a=0,b=0,c=0,d=0,r,option,buying;
system("cls");
cout<<">酷炫賽馬場< 第"<<n++<<"局"<<endl;
cout<<"=========================================================================|終點"<<endl;
cout<<"∞"<<endl;
cout<<"△"<<endl;
cout<<"◇"<<endl;
cout<<"☆"<<endl;
cout<<endl;
cout<<"可用餘額:"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入 :";
cin>>buying;
balance+=buying;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"=========================================================================|終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"∞"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"△"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◇"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆"<<endl;
system("cls");
}
cout<<"比賽結束 由";
if(a==75)
cout<<"∞";
else if(b==75)
cout<<"△";
else if(c==75)
cout<<"◇";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"=========================================================================|終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"∞"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"△"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◇"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆"<<endl;
system("pause");
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2014-4-27 10:06
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int e=1, balance=0;
re1:
int a=0, b=0, c=0, d=0, r, option, buyin;
system("cls");
cout<<"$賺大錢賽馬場$ 第"<<e<<"局"<<endl;
cout<<"------------------------------------------------------------------------│終點"<<endl;
cout<<"◢ 1▋"<<endl;
cout<<"◢ 2▋"<<endl;
cout<<"◢ 3▋"<<endl;
cout<<"◢ 4▋"<<endl;
cout<<endl<<"可用餘額:"<<balance<<"元!"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=73 && b!=73 && c!=73 && d!=73)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------│終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢ 1▋"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢ 2▋"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢ 3▋"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢ 4▋"<<endl;
system("cls");
}
cout<<"比賽結束"<<endl;
if(a==73)
cout<<"由"<<"◢ 1▋"<<"先馳得點"<<endl;
if(b==73)
cout<<"由"<<"◢ 2▋"<<"先馳得點"<<endl;
if(c==73)
cout<<"由"<<"◢ 3▋"<<"先馳得點"<<endl;
if(d==73)
cout<<"由"<<"◢ 4▋"<<"先馳得點"<<endl;
cout<<"------------------------------------------------------------------------│終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢ 1▋"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢ 2▋"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢ 3▋"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢ 4▋"<<endl;
system("pause");
e++;
goto re1;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2