標題:
賽馬程式 (七)
[打印本頁]
作者:
陳品肇
時間:
2019-1-4 23:42
標題:
賽馬程式 (七)
完成選項 (3)離開 的相對應程式碼
在離開時顯示戰果, 譬如:
"沒輸沒贏! 全身而退!"
"恭喜你! 這次總共贏了100元!"
"不好意思! 讓你損失了200元!"
[attach]5685[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0,winner,money=0;
re1:
int a=0, b=0, c=0, d=0, r, option, buyin, bet;
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;
}else if(option==2)
{
if(balance==0)
{
cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
system("pause");
goto re1;
}
cout<<"下注: ";
cin>>bet;
if(bet>balance)
{
cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
system("pause");
goto re1;
}else
{
cout<<endl<<"(1)◆ (2)★ (3)▲ (4)● 請選擇: ";
cin>>option;
cout<<"比賽即將開始..."<<endl<<endl;
system("pause");
}
}else if(option==3)
{
goto end;
}else
{
cout<<"輸入錯誤!"<<endl;
system("pause");
goto re1;
}
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<<"◆";
winner=1;
}
else if(b==75)
{
cout<<"★";
winner=2;
}
else if(c==75)
{
cout<<"▲";
winner=3;
}
else
{
cout<<"●";
winner=4;
}
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<<endl;
if(option==winner)
{
cout<<"贏了"<<bet*3<<"元!"<<endl;
balance+=bet*3;
money+=bet*3;
}else
{
cout<<"損失"<<bet<<"元!"<<endl;
balance-=bet;
money-=bet;
}
system("pause");
n++;
goto re1;
end:
if(money==0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
}else if(money>0)
{
cout<<"恭喜你! 這次總共贏了"<<money<<"元!"<<endl;
}else
{
cout<<"不好意思! 讓你損失了"<<money<<"元!"<<endl;
}
cout<<"謝謝光臨! 下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳柏霖
時間:
2019-1-5 17:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=1 ,mony=0 ,end;
re:
int a=0 ,b=0 ,c=0 ,d=0 ,z ,win ,buy ,bird ,n ,many;
srand(time(NULL));
cout<<"第"<<x<<"場[萬事如意]賽馬場"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"㊣"<<endl;
cout<<"▼"<<endl<<endl;
cout<<"可用餘額:"<<mony<<"元"<<endl;
cout<<"(1)買入(2)下注(3)離開 請選擇:";
cin>>z;
if(z==1)
{
cout<<"買入:";
cin>>buy;
mony=mony+buy;
system("cls");
goto re;
}else if(z==2)
{
if(mony==0)
{
cout<<"餘額不足!請先買入!";
system("pause");
system("cls");
goto re;
}
cout<<"下注:";
cin>>bird;
if(bird>mony)
{
cout<<"餘額不足!請先買入!";
system("pause");
system("cls");
goto re;
}else if(bird<=mony)
{
cout<<"(1)■(2)★(3)㊣(4)▼ 請選擇:";
cin>>many;
cout<<"比賽即將開始>>>"<<endl<<endl;
system("pause");
}
}else if(z==3)
{
goto go;
}else
{
cout<<"輸入錯誤";
system("pause");
system("cls");
goto re;
}
while(a!=70 && b!=70 && c!=70 && d!=70)
{
cout<<"比賽中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
z=rand()%4+1;
if(z==1)
{
a+=2;
}
if(z==2)
{
b+=2;
}
if(z==3)
{
c+=2;
}
if(z==4)
{
d+=2;
}
for(int i=0; i<=a; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0; i<=b; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0; i<=c; i++)
{
cout<<" ";
}
cout<<"㊣"<<endl;
for(int i=0; i<=d; i++)
{
cout<<" ";
}
cout<<"▼"<<endl;
system("cls");
}
cout<<"第"<<x<<"場比賽結束 由";
if(a==70)
{
cout<<"◆";
win=1;
}else if(b==70)
{
cout<<"★";
win=2;
}else if(c==70)
{
cout<<"㊣";
win=3;
}else
{
cout<<"▼";
win=4;
}
cout<<"先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=a; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0; i<=b; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0; i<=c; i++)
{
cout<<" ";
}
cout<<"㊣"<<endl;
for(int i=0; i<=d; i++)
{
cout<<" ";
}
cout<<"▼"<<endl;
cout<<"按任意鍵進行下一場比賽"<<endl;
if(win==many)
{
mony=mony+bird*3;
end=end+bird*3;
}else
{
mony=mony-bird;
end=end-bird;
}
system("pause");
system("cls");
x++;
goto re;
go:
if(end=0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
}else if(end>0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
}else
{
cout<<"不好意思! 讓你損失了200元!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2019-1-5 17:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int balance=0, total=0;
start:
srand(time(NULL));
int space[]={0,0,0,0};
int option, money, winer, bet;
system("cls");
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>>money;
balance+=money;
goto start;
}else if(option==2)
{
cout<<"下注:";
cin>>bet;
if (bet>money)
{
cout<<"可用餘額不足!請先買入"<<endl;
system("pause");
goto start;
}else
{
cout<<"(1)◆ (2)★ (3)▲ (4)●請選擇: "<<endl;
cin>>option;
}
}else if(option==3)
{
goto end;
}
system("pause");
while (true)
{
int r=rand()%4;
space[r]++;
if(space[r]==74)
break;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=space[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int j=0;j<=space[1]; j++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int j=0;j<=space[2];j++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int j=0;j<=space[3];j++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(space[0]==74)
{
cout<<"◆";
winer =1;
}
else if(space[1]==74)
{
cout<<"★";
winer =2;
}
else if(space[2]==74)
{
cout<<"▲";
winer =3;
}
else
{
cout<<"●";
winer =4;
}
cout<<" 先到達終點!"<<endl;
cout<<"比賽結束"<<endl;
cout<<"--------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=space[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int j=0;j<=space[1]; j++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int j=0;j<=space[2];j++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int j=0;j<=space[3];j++)
{
cout<<" ";
}
cout<<"●"<<endl;
if (option==winer)
{
balance = balance+ bet*3;
total = total+ bet*3;
}
else
{
balance = balance- bet;
total = total- bet;
}
end:
if(total==0)
{
cout<<"沒輸沒贏!"<<endl;
}else if(total>0)
{
cout<<"恭喜你! 這次總共贏了"<<total<<"元!"<<endl;
}else
{
cout<<"不好意思! 你損失了"<<total<<"元!"<<endl;
}
system("pause");
goto start;
system("pause");
return 0;
}
複製代碼
作者:
蔡季庭
時間:
2019-1-5 17:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0,winner,total=0;
re1:
int a=0, b=0, c=0, d=0, r, option, buyin, bet;
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;
}else if(option==2)
{
if(balance==0)
{
cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
system("pause");
goto re1;
}
cout<<"下注: ";
cin>>bet;
if(bet>balance)
{
cout<<"可用餘額不足! 請先買入!"<<endl<<endl;
system("pause");
goto re1;
}else
{
cout<<endl<<"(1)◆ (2)★ (3)▲ (4)● 請選擇: ";
cin>>option;
cout<<"比賽即將開始..."<<endl<<endl;
system("pause");
}
}else if(option==3)
{
goto end;
}else
{
cout<<"輸入錯誤!"<<endl;
system("pause");
goto re1;
}
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<<"◆";
winner=1;
}
else if(b==75)
{
cout<<"★";
winner=2;
}
else if(c==75)
{
cout<<"▲";
winner=3;
}
else
{
cout<<"●";
winner=4;
}
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<<endl;
if(option==winner)
{
cout<<"贏了"<<bet*3<<"元!"<<endl;
balance+=bet*3;
total+=bet*3;
}else
{
cout<<"損失ASS"<<bet<<"元!"<<endl;
balance-=bet;
total-=bet;
}
system("pause");
n++;
goto re1;
end:
if(total==0)
{
cout<<"沒輸沒贏! 全身而退!"<<endl;
}else if(total>0)
{
cout<<"恭喜你! 這次總共贏了"<<total<<"元!"<<endl;
}else
{
cout<<"不好意思! 讓你損失了"<<total<<"元!"<<endl;
}
cout<<"謝謝光臨! 下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2019-1-5 17:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,money=0,total=0;
re1:
int a=0, b=0, c=0, d=0, r,option,winer,buying,bet;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl<<endl;
cout<<"可用餘額: "<< money<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1) //選擇買入多少籌碼
{
cout<<"買入:";
cin>>buying;
money = money + buying; // 原始的餘額加上買入的籌碼
goto re1;
}else if(option==2)
{
if(money==0) //一開始就沒有餘額
{
cout<<"可用餘額不足!請先買入!"<<endl;
system("pause");
goto re1;
}
cout<<"下注:";
cin>> bet;
if(bet>money) //餘額< 下注金額
{
cout<<"可用餘額不足!請先買入!"<<endl;
system("pause");
goto re1;
}else
{
dog:
cout<<"(1)◆(2)★(3)▲(4)● 請選擇: "<<endl;
cin>>option;
if(option>4)
{
cout<<"你選錯了"<<endl;
system("pause");
goto dog;
}
cout<<"比賽即將開始..."<<endl<<endl;
system("pause");
}
}else if(option==3)
{
goto end;
}else
{
cout<<"輸入錯誤!!"<<endl;
system("pause");
goto re1;
}
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<<"◆";
winer=1;
}
else if(b==75)
{
cout<<"★";
winer=2;
}
else if(c==75)
{
cout<<"▲";
winer=3;
}
else
{
cout<<"●";
winer=4;
}
cout<<" 先馳得點!"<<endl;
// 印出最後4匹馬的結果
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;
if(winer==option)
{
money=money+bet*3;
total=total+bet*3;
}else
{
money=money-bet;
total=total-bet;
}
system("pause");
n++;
goto re1;
end:
if(total==0)
{
cout<<"你竟然沒賠錢!!!!"<<endl;
}else if(total>0)
{
cout<<"贏錢ㄟ,阿不就好棒棒"<<endl;
}else
{
cout<<"那個白癡連賭博都贏不了啊"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
戴唯陞
時間:
2019-1-5 17:27
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0,winner,money=0;
re1:
int a=0, b=0, c=0, d=0, r,option,buying,bet;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<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 = balance + buying;
goto re1;
}else if(option==2)
{
if(balance==0)
{
cout<<"可用餘額不足!請先買入!"<<endl;
system("pause");
goto re1;
}
cout<<"下注:";
cin>> bet;
if(bet>balance)
{
cout<<"可用餘額不足!請先買入!"<<endl;
system("pause");
goto re1;
} else if(bet < balance)
{
cout<<"(1)◆(2)★(3)▲(4)● 請選擇: "<<endl;
cin>>option;
cout<<"比賽即將開始..."<<endl<<endl;
system("pause");
}
} else if(option==3)
{
goto end;
} else
{
cout<<"輸入錯誤!"<<endl;
system("pause");
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<<"◆";
winner = 1;
}
else if(b==75)
{
cout<<"★";
winner = 2;
}
else if(c==75)
{
cout<<"▲";
winner = 3;
}
else
{
cout<<"●";
winner =4;
}
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;
if(option==winner)
{
cout<<"贏了"<<bet*3<<"元"<<endl;
balance+=bet*3;
money+=bet*3;
}
else
{
cout<<"輸了"<<bet<<"元"<<endl;
balance-=bet;
money-=bet;
}
system("pause");
n++;
goto re1;
end:
if(money==0)
{
cout<<"沒輸沒贏"<<endl;
}
else if (money>0)
{
cout<<"恭喜贏了"<<money<<"元"<<endl;
}
else
{
cout<<"輸了"<<money<<"元"<<endl;
}
cout<<"謝謝下次再光臨"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴安利
時間:
2019-1-5 17:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, money=0, total=0;
re:
int a=0, b=0, c=0, d=0, r, option, buyin, bet, winner;
system("cls");
cout<<"+++好事成雙->賽馬場+++ 第"<<n<<"局"<<endl;
cout<<"-------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<money<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇"<<endl;
cin>>option;
if(option==1)
{
cout<<"買入:"<<endl;
cin>>buyin;
money+=buyin;
goto re;
}
else if(option==2)
{
if(money==0)
{
cout<<"可用餘額不足!請先買入!!"<<endl;
system("pause");
goto re;
}
cout<<"下注:";
cin>>bet;
if(bet>money)
{
cout<<"可用餘額不足!請先買入!!"<<endl;
system("pause");
goto re;
}
else
{
cout<<"(1)◆(2)★(3)▲(4)● 請選擇:"<<endl;
cin>>option;
cout<<"比賽即將開始....."<<endl<<endl;
system("pause");
}
}
else if(option==3)
{
goto end;
}
else
{
cout<<"輸入錯誤"<<endl;
system("pause");
goto re;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=20 && b!=20 && c!=20 && d!=20)
{
cout<<"賽馬進行中..."<<endl;
cout<<"-------------------------------------------|終點"<<endl;
r = rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==4)
d++;
for(int i=0;i<=a;i++)
cout<<" ";
cout<<"◆"<<endl;
a++;
for(int i=0;i<=b;i++)
cout<<" ";
cout<<"★"<<endl;
b++;
for(int i=0;i<=c;i++)
cout<<" ";
cout<<"▲"<<endl;
c++;
for(int i=0;i<=d;i++)
cout<<" ";
cout<<"●"<<endl;
d++;
system("cls");
}
cout<<"賽馬結束...!由 ";
if(a==20)
{
cout<<"◆";
winner = 1;
}
else if(b==20)
{
cout<<"★";
winner = 2;
}
else if(c==20)
{
cout<<"▲";
winner = 3;
}
else
{
cout<<"●";
winner = 4;
}
cout<<"先抵達終點!"<<endl;
cout<<"-------------------------------------------|終點"<<endl;
for(int i=0;i<=a;i++)
cout<<" ";
cout<<"◆"<<endl;
a++;
for(int i=0;i<=b;i++)
cout<<" ";
cout<<"★"<<endl;
b++;
for(int i=0;i<=c;i++)
cout<<" ";
cout<<"▲"<<endl;
c++;
for(int i=0;i<=d;i++)
cout<<" ";
cout<<"●"<<endl;
d++;
if(option==winner)
{
cout<<"贏了"<<bet*3<<"元!"<<endl;
money+=bet*3;
total+=bet*3;
}else
{
cout<<"損失"<<bet<<"元!"<<endl;
money-=bet;
total-=bet;
}
system("pause");
n++;
goto re;
end:
if(total==0)
{
cout<<"沒輸沒贏!"<<endl;
}
else if(total>0)
{
cout<<"恭喜!這次共贏了:"<<total<<"元"<<endl;
}
else
{
cout<<"可惜!你損失了:"<<total<<"元"<<endl;
}
cout<<"謝謝光臨!!!下次再來~~~"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴偉宸
時間:
2019-1-5 17:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,money=0,winner,winmoney=0;
re1:
int a=0, b=0, c=0, d=0, r,option,bet,buyin;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl<<endl;
cout<<"可用餘額: "<< money<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
money = money + buyin;
goto re1;
}else if(option==2)
{
if(money==0)
{
cout<<"可用餘額不足!請先買入!"<<endl;
system("pause");
goto re1;
}
cout<<"下注:";
cin>> bet;
if(bet>money)
{
cout<<"可用餘額不足!請先買入!"<<endl;
system("pause");
goto re1;
}else
{
cout<<"(1)◆(2)★(3)▲(4)● 請選擇: "<<endl;
cin>>option;
cout<<"比賽即將開始..."<<endl<<endl;
system("pause");
}
}else if(option==3)
{
goto end;
}else
{
cout<<"輸入錯誤!!"<<endl;
system("pause");
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && d!=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<<"◆"<<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==70)
{
cout<<"◆";
winner=1;
}
else if(b==70)
{
cout<<"★";
winner=2;
}
else if(c==70)
{
cout<<"▲";
winner=3;
}
else
{
cout<<"●";
winner=4;
}
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;
if(option==winner)
{
cout<<"贏了"<<bet*3<<"元!"<<endl;
money+=bet*3;
winmoney+=bet*3;
}
else{
cout<<"損失"<<bet<<"元!"<<endl;
money-=bet;
winmoney-=bet;
}
system("pause");
n++;
goto re1;
end:
if(winmoney==0)
{
cout<<"沒輸沒贏,全身而退!"<<endl;
}
else if(winmoney>0)
{
cout<<"恭喜你!這次總共贏了"<<winmoney<<"元"<<endl;
}
else
{
cout<<"不好意?,讓您損失了"<<winmoney<<"元"<<endl;
}
cout<<"謝謝光臨!下次再來!"<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2