標題:
[作業] 賽馬程式 (七)
[打印本頁]
作者:
歐柏罕
時間:
2018-5-28 20:27
標題:
[作業] 賽馬程式 (七)
完成選項 (3)離開 的相對應程式碼
在離開時顯示戰果, 譬如:
"沒輸沒贏! 全身而退!"
"恭喜你! 這次總共贏了100元!"
"不好意思! 讓你損失了200元!"
本帖隱藏的內容需要回復才可以瀏覽
作者:
彭煥宇
時間:
2018-5-28 20:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player;
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
if(s[r]==45)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
n++;
if(winner==player)
{
cout<<"你贏了"<<bet*3<<"元!"<<endl;
balance+=bet*3;
}
else
{
cout<<"你輸了"<<bet<<"元!"<<endl;
balance-=bet;
}
system("pause");
goto re;
end:
if(balance>0)
{
cout<<"恭喜你! 這次總共贏了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else if(balance<0)
{
cout<<"不好意思! 讓你損失了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else (balance==0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
cout<<endl<<"慢走!"<<endl;
}
_sleep(1500);
return 0;
}
複製代碼
作者:
洪翊庭
時間:
2018-5-28 20:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player;
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
if(s[r]==45)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
n++;
if(winner==player)
{
cout<<"你贏了"<<bet*3<<"元!"<<endl;
balance+=bet*3;
}
else
{
cout<<"你輸了"<<bet<<"元!"<<endl;
balance-=bet;
}
system("pause");
goto re;
end:
if(balance>0)
{
cout<<"恭喜你! 這次總共贏了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else if(balance<0)
{
cout<<"不好意思! 讓你損失了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else (balance==0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
cout<<endl<<"慢走!"<<endl;
}
_sleep(1500);
return 0;
}
複製代碼
作者:
黃宇綸
時間:
2018-5-28 20:51
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player,w=0.;
string l[]={"★","◆","●","▲"};
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
cout<<"★"<<endl;
cout<<"◆"<<endl;
cout<<"●"<<endl;
cout<<"▲"<<endl;
cout<<endl<<"可用餘額: "<<balance<<" 元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"[1]★ [2]◆ [3]● [4]▲ 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]+=2;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"●"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"▲"<<endl;
if(s[r]==46)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<l[winner-1]<<" 選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"●"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"▲"<<endl;
if(player==winner)
{
cout<<"增加 "<<bet*3<<"元"<<endl;
balance+=bet*3;
w+=bet*3;
system("pause");
goto re;
}
else
{
cout<<"損失 "<<bet<<"元"<<endl;
balance-=bet;
w-=bet;
system("pause");
goto re;
}
n++;
system("pause");
goto re;
end:
if(w==0)
cout<<endl<<"沒輸沒贏! 全身而退!"<<endl;
else if(w>0)
cout<<endl<<"恭喜你! 這次總共贏了"<<w<<"元!"<<endl;
else
cout<<endl<<"不好意思! 讓你損失了"<<-w<<"元"<<endl;
cout<<endl<<"謝謝光臨! 下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
盧佑芯
時間:
2018-5-28 21:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player;
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4; //0~3
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
if(s[r]==45)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
n++;
if(winner=player)
{
cout<<"贏了"<<bet*3<<"元"<<endl;
balance+=bet*3;
}
else
{
cout<<"損失"<<bet<<"元"<<endl;
balance-=bet;
}
if(balance==0)
cout<<"沒輸沒贏!全身而退!"<<endl;
else if(balance>0)
cout<<"恭喜你!總共賺進"<<balance<<"元!"<<endl;
else
cout<<"不好意思!總共損失了"<<-balance<<"元!"<<endl;
cout<<"謝謝光臨!下次再來!"<<endl;
system("pause");
goto re;
end:
cout<<endl<<"慢走!"<<endl;
_sleep(1500);
return 0;
}
複製代碼
作者:
李治毅
時間:
2018-6-2 11:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int x=1,balance=0,option,buyin,bet,player,wallet=0;
re:
system("cls");
string n[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r;
cout<<"「好事成雙」賽馬場 第"<<x<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<n[i]<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
if(buyin<=0)
{
cout<<"輸入錯誤!"<<endl;
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!"<<endl;
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!"<<endl;
_sleep(1500);
goto re;
}
cout<<endl<<"(1)◆ (2)★ (3)▲ (4)● 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}else if(option==3)
{
goto end;
}else
{
cout<<"輸入錯誤!"<<endl;
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4; //0~3
s[r]++;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
_sleep(10);
system("cls");
if(s[r]==76)
break;
}
cout<<"比賽結果! 由 "<<n[r]<<" 先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
if(player-1==r)
{
cout<<"贏了 "<<bet*3<<"元!";
balance+=bet*3;
wallet+=bet*3;
}else
{
cout<<"損失 "<<bet<<"元";
balance-=bet;
wallet-=bet;
}
cout<<endl<<endl;
system("pause");
x++;
goto re;
end:
cout<<endl;
if(wallet==0)
cout<<"沒輸沒贏! 全身而退!"<<endl<<endl;
else if(wallet>0)
cout<<"恭喜你! 這次總共贏了"<<wallet<<"元!"<<endl<<endl;
else
cout<<"不好意思! 讓你損失了"<<-wallet<<"元!"<<endl<<endl;
cout<<"謝謝光臨! 下次再來!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
李沛昂
時間:
2018-6-3 21:30
本帖最後由 李沛昂 於 2018-6-11 16:53 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int dog=1;
int pig1,pig2=0,pig3=0,pig4,pig5,pig6,pig7;
re:
int a,b,c;
system("cls");
int pig[]={0,0,0,0};
srand(time(NULL));
cout<<"「好事成雙」賭馬場 第"<<dog<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl<<"可用餘額: "<<pig3<<endl<<endl;
re3:
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>pig2;
if(pig2==1)
{
re1:
cout<<"買入: ";
cin>>pig4;
if(pig4<=0)
{
cout<<"你是白癡嗎?看清楚!!!"<<endl;
_sleep(1500);
goto re1;
}
pig3+=pig4;
goto re;
}
if(pig2==2)
{
cout<<"下注: ";
cin>>pig5;
if(pig5<=0)
{
cout<<"你是白癡嗎?看清楚!!!"<<endl;
_sleep(1500);
goto re1;
}
if(pig5>pig3)
{
cout<<"餘額不夠,請買入!"<<endl;
_sleep(1500);
goto re1;
}
cout<<"請選擇 (1)◆(2)★(3)▲(4)●: ";
cin>>pig6;
cout<<"比賽即將開始......"<<endl;
_sleep(1500);
goto re2;
}
if(pig2==3)
{
goto end;
}
else
{
cout<<"你是白癡嗎?看清楚!!!"<<endl;
_sleep(1500);
goto re3;
}
system("pause");
re2:
while(true)
{
system("cls");
pig1=rand()%4;
pig[pig1]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=pig[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0;i<=pig[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0;i<=pig[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0;i<=pig[3];i++)
cout<<" ";
cout<<"●"<<endl;
if(pig[pig1]==73)
break;
_sleep(25);
}
system("cls");
if(pig1==0)
cout<<"比賽結束!"<<" 由◆先馳得點!"<<endl;
else if(pig1==1)
cout<<"比賽結束!"<<" 由★先馳得點!"<<endl;
else if(pig1==2)
cout<<"比賽結束!"<<" 由▲先馳得點!"<<endl;
else
cout<<"比賽結束!"<<" 由●先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=pig[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0;i<=pig[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0;i<=pig[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0;i<=pig[3];i++)
cout<<" ";
cout<<"●"<<endl;
if(pig6==1 && pig1==0)
{
cout<<"獲得"<<pig5*3<<"元!"<<endl;
pig7+=pig5*3;
pig3+=pig5*3;
}else if(pig6==2 && pig1==1)
{
cout<<"獲得"<<pig5*3<<"元!"<<endl;
pig7+=pig5*3;
pig3+=pig5*3;
}else if(pig6==3 && pig1==2)
{
cout<<"獲得"<<pig5*3<<"元!"<<endl;
pig7+=pig5*3;
pig3+=pig5*3;
}else if(pig6==4 && pig1==3)
{
cout<<"獲得"<<pig5*3<<"元!"<<endl;
pig7+=pig5*3;
pig3+=pig5*3;
}else
{
cout<<"損失"<<pig5<<"元!"<<endl;
pig7-=pig5;
pig3-=pig5;
}
system("pause");
dog++;
goto re;
end:
if(pig7>0)
{
cout<<"恭喜你! 這次總共贏了"<<pig7<<"元!"<<endl;
}
else if(pig7==0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
}
else
{
cout<<"對不起! 讓你損失了"<<-pig7<<"元!"<<endl;
}
cout<<endl<<"謝謝光臨! 下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪翊展
時間:
2018-6-4 17:46
本帖最後由 洪翊展 於 2018-6-4 19:57 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player;
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
if(s[r]==45)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
n++;
if(winner==player)
{
cout<<"你贏了"<<bet*3<<"元!"<<endl;
balance+=bet*3;
}
else
{
cout<<"你輸了"<<bet<<"元!"<<endl;
balance-=bet;
}
system("pause");
goto re;
end:
if(balance>0)
{
cout<<"恭喜你! 這次總共贏了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else if(balance<0)
{
cout<<"不好意思! 讓你損失了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
cout<<endl<<"慢走!"<<endl;
}
_sleep(1500);
return 0;
}
複製代碼
作者:
沈子晏
時間:
2018-6-4 18:03
本帖最後由 沈子晏 於 2018-6-4 20:07 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1;
int buy=0;
int select=0;
int point=0;
int win=0;
int play=0;
int bet=0;
re:
system("CLS");
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
srand(time(NULL));
int s[]={0,0,0,0};
int speed=50;
int r=0;
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
cout<<"4"<<endl;
cout<<"可用餘額:"<<point<<"元"<<endl;
cout<<"(1)儲值 (2)下注 (3)離開 請選擇:";
cin>>select;
if(select==1)
{
cout<<"儲值:";
cin>>buy;
point+=buy;
goto re;
}
if (select==2)
{
cout<<"下注:";
cin>>buy;
if(buy<=0)
{
cout<<"輸入錯誤";
_sleep(1500);
goto re;
}
if(buy>point)
{
cout<<"可用餘額不足,請先儲值";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: "<<endl;
cin>>play;
cout<<"比賽將開始......"<<endl<<endl;
}
system("pause");
while(true)
{
system("CLS");
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4;//? 0-3
s[r]++;
for(int i=0;i<=s[0];i++)
{
cout<<" ";
}
cout<<"1"<<endl;
for(int i=0;i<=s[1];i++)
{
cout<<" ";
}
cout<<"2"<<endl;
for(int i=0;i<=s[2];i++)
{
cout<<" ";
}
cout<<"3"<<endl;
for(int i=0;i<=s[3];i++)
{
win==r+1;
cout<<" ";
}
cout<<"4"<<endl;
if(s[r]==73)
{
break;
}
_sleep(1);
}
system("CLS");
n++;
cout<<"比賽結束! 由"<< r+1 <<"先馳得名"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=s[0];i++)
{
cout<<" ";
}
cout<<"1"<<endl;
for(int i=0;i<=s[1];i++)
{
cout<<" ";
}
cout<<"2"<<endl;
for(int i=0;i<=s[2];i++)
{
cout<<" ";
}
cout<<"3"<<endl;
for(int i=0;i<=s[3];i++)
{
cout<<" ";
}
cout<<"4"<<endl;
if(win==play)
{
cout<<"贏得"<< buy*3 <<"元"<<endl;
point=point+buy*3;
}
else
{
cout<<"損失"<< buy <<"元"<<endl;
point=point-buy;
}
if(point>0)
{
cout<<"不好意思! 讓你損失了"<<-point<<"元"<<endl;
}
else if(point<0)
{
cout<<"恭喜你! 這次總共贏了"<<point<<"元"<<endl;
}
else
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
}
if(select==3)
{
goto re;
}
system("pause");
goto re;
return 0;
}
複製代碼
作者:
黃宇瑄
時間:
2018-6-4 19:48
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player,w=0.;
string l[]={"★","◆","●","▲"};
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
cout<<"★"<<endl;
cout<<"◆"<<endl;
cout<<"●"<<endl;
cout<<"▲"<<endl;
cout<<endl<<"可用餘額: "<<balance<<" 元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"[1]★ [2]◆ [3]● [4]▲ 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]+=2;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"●"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"▲"<<endl;
if(s[r]==46)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<l[winner-1]<<" 選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"●"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"▲"<<endl;
if(player==winner)
{
cout<<"增加 "<<bet*3<<"元"<<endl;
balance+=bet*3;
w+=bet*3;
system("pause");
goto re;
}
else
{
cout<<"損失 "<<bet<<"元"<<endl;
balance-=bet;
w-=bet;
system("pause");
goto re;
}
n++;
system("pause");
goto re;
end:
if(w==0)
cout<<endl<<"沒輸沒贏! 全身而退!"<<endl;
else if(w>0)
cout<<endl<<"恭喜你! 這次總共贏了"<<w<<"元!"<<endl;
else
cout<<endl<<"不好意思! 讓你損失了"<<-w<<"元"<<endl;
cout<<endl<<"謝謝光臨! 下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
盧佑恩
時間:
2018-6-4 19:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player;
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
if(s[r]==45)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
n++;
system("pause");
if(winner==player)
{
cout<<"贏了"<<endl;
cout<<"贏得"<<bet*3<<"塊錢"<<endl;
balance+=bet*3;
}
else
{
cout<<"輸了";
balance-bet;
}
system("pause");
goto re;
end:
if(balance>0)
{
cout<<"恭喜你! 這次總共贏了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
else if(balance<0)
{
cout<<"不好意思! 讓你損失了"<<balance<<"元"<<endl;
cout<<endl<<"慢走!"<<endl;
}
_sleep(1500);
return 0;
}
複製代碼
作者:
啓銓
時間:
2018-6-4 19:57
0000000000000000000000000000000
作者:
曾堂桂
時間:
2018-6-4 19:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int x=1,balance=0,option,buyin,bet,player,wallet=0;
re:
system("cls");
string n[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r;
cout<<"「好事成雙」賽馬場 第"<<x<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<n[i]<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
if(buyin<=0)
{
cout<<"輸入錯誤!"<<endl;
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!"<<endl;
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!"<<endl;
_sleep(1500);
goto re;
}
cout<<endl<<"(1)◆ (2)★ (3)▲ (4)● 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}else if(option==3)
{
goto end;
}else
{
cout<<"輸入錯誤!"<<endl;
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4;
s[r]++;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
_sleep(10);
system("cls");
if(s[r]==76)
break;
}
cout<<"比賽結果! 由 "<<n[r]<<" 先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
if(player-1==r)
{
cout<<"贏了 "<<bet*3<<"元!";
balance+=bet*3;
wallet+=bet*3;
}else
{
cout<<"損失 "<<bet<<"元";
balance-=bet;
wallet-=bet;
}
cout<<endl<<endl;
system("pause");
x++;
goto re;
end:
cout<<endl;
if(wallet==0)
cout<<"沒輸沒贏! 全身而退!"<<endl<<endl;
else if(wallet>0)
cout<<"恭喜你! 這次總共贏了"<<wallet<<"元!"<<endl<<endl;
else
cout<<"不好意思! 讓你損失了"<<-wallet<<"元!"<<endl<<endl;
cout<<"謝謝光臨! 下次再來!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
盧佑芯
時間:
2018-6-4 20:10
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, winner, balance=0, option, buyin, bet, player,wallet=0;
srand(time(NULL));
re:
system("cls");
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"可用餘額不足,請先買入!";
_sleep(1500);
goto re;
}
cout<<endl<<"1號 2號 3號 4號 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"- - - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
if(s[r]==45)
{
winner=r+1;
break;
}
_sleep(60);
}
system("cls");
cout<<"比賽結束! 由 "<<winner<<" 號選手先馳得點!"<<endl;
cout<<"- - - - - - - - - - - - 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"1"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"2"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"3"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"4"<<endl;
n++;
if(winner==player)
{
cout<<"贏了"<<bet*3<<"元"<<endl;
balance+=bet*3;
wallet+=bet*3;
}
else
{
cout<<"損失"<<bet<<"元"<<endl;
balance-=bet;
wallet-=bet;
}
system("pause");
goto re;
end:
if(wallet==0)
cout<<"沒輸沒贏!全身而退!"<<endl;
else if(wallet>0)
cout<<"恭喜你!總共賺進"<<wallet<<"元!"<<endl;
else
cout<<"不好意思!總共損失了"<<-wallet<<"元!"<<endl;
cout<<"謝謝光臨!下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
啓銓
時間:
2018-6-4 20:11
本帖最後由 啓銓 於 2018-6-4 20:29 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int x=1,balance=0,option,buyin,bet,player,wallet=0;
re:
system("cls");
string n[]={"馬","馬英九","馬友友","歐巴馬"};
int s[]={0,0,0,0};
int r;
cout<<"「射後不理」賭馬場 第"<<x<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<n[i]<<endl;
cout<<endl<<"你剩的錢: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買 (2)下注 (3)滾蛋 選擇: ";
cin>>option;
if(option==1)
{
cout<<"買: ";
cin>>buyin;
if(buyin<=0)
{
cout<<"白癡連這都不會!"<<endl;
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}else if(option==2)
{
cout<<"下注: ";
cin>>bet;
if(bet<=0)
{
cout<<"媽的你博罕嗎?"<<endl;
_sleep(1500);
goto re;
}
if(bet>balance)
{
cout<<"你先去夜市當乞丐"<<endl;
_sleep(1500);
goto re;
}
cout<<endl<<"(1)馬 (2)馬英九 (3)馬友友 (4)歐巴馬 請選擇: ";
cin>>player;
cout<<"比賽即將開始..."<<endl<<endl;
}else if(option==3)
{
goto end;
}else
{
cout<<"拜託你先去看醫生!"<<endl;
_sleep(1500);
goto re;
}
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4; //0~3
s[r]++;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
_sleep(10);
system("cls");
if(s[r]==76)
break;
}
cout<<"比賽結果! 由 "<<n[r]<<" 先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
if(player-1==r)
{
cout<<"贏了 "<<bet*3<<"元!";
balance+=bet*3;
wallet+=bet*3;
}else
{
cout<<"損失 "<<bet<<"元";
balance-=bet;
wallet-=bet;
}
cout<<endl<<endl;
system("pause");
x++;
goto re;
end:
cout<<endl;
if(wallet==0)
cout<<"沒輸沒贏! 不要再賭了!"<<endl<<endl;
else if(wallet>0)
cout<<"恭喜你! 贏了"<<wallet<<"元!"<<endl<<endl;
else
cout<<"你是豬哥亮嗎?"<<-wallet<<"元!"<<endl<<endl;
cout<<"謝謝光臨! 下次再來!"<<endl<<endl;
system("pause");
return 0;
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2