標題:
賽馬程式 (六)
[打印本頁]
作者:
陳品肇
時間:
2019-1-4 23:40
標題:
賽馬程式 (六)
1. 比對比賽結果與玩家下注, 判斷玩家贏了錢還是輸了錢.
2. 對變數balance做加減, 使可用餘額會隨著玩家輸贏而增減.
規則如下:
若最後勝出的選手與玩家下注相同, 玩家贏得下注金3倍的錢.
反之, 玩家損失下注金.
[attach]5682[/attach]
[attach]5683[/attach]
[attach]5684[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0,winner;
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;
}else
{
cout<<"損失"<<bet<<"元!"<<endl;
balance-=bet;
}
system("pause");
n++;
goto re1;
end:
system("pause");
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2019-1-5 16:44
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,money=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;
}else
{
money=money-bet;
}
system("pause");
n++;
goto re1;
end:
system("pause");
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2019-1-5 16:45
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int balance=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;
}
cout<<"下注:";
cin>>bet;
if (bet>money)
{
cout<<"可用餘額不足!請先買入"<<endl;
system("pause");
goto start;
}else
{
cout<<"(1)◆ (2)★ (3)▲ (4)●請選擇: "<<endl;
cin>>option;
}
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;
}
else
{
balance = balance- bet;
}
system("pause");
goto start;
system("pause");
return 0;
}
複製代碼
作者:
蔡季庭
時間:
2019-1-5 16:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,money=0;
re1:
int a=0, b=0, c=0, d=0, r,option,winner,bet,buying;
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
{
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; //產生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+1;
}
else if(c==75)
{
cout<<"▲";
winner+1;
}
else
{
cout<<"●";
winner+1;
}
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(winner==option)
{
money = money+ bet*3;
}else
{
money = money - bet ;
}
system("pause");
n++;
goto re1;
end:
system("pause");
return 0;
}
複製代碼
作者:
戴唯陞
時間:
2019-1-5 16:52
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0,winner;
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<<"元"<<endl;
balance+=bet*3;
}
else
{
cout<<"輸了"<<bet<<"元"<<endl;
balance-=bet;
}
system("pause");
n++;
goto re1;
end:
system("pause");
return 0;
}
複製代碼
作者:
陳柏霖
時間:
2019-1-5 16:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=1 ,mony=0 ,many;
re:
int a=0 ,b=0 ,c=0 ,d=0 ,z ,win ,buy ,bird ,n;
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;
}
system("pause");
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;
}else
{
mony=mony-bird;
}
system("pause");
system("cls");
x++;
goto re;
go:
system("pause");
return 0;
}
複製代碼
作者:
戴偉宸
時間:
2019-1-5 16:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,money=0,winner;
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;
}
else{
cout<<"損失"<<bet<<"元!"<<endl;
money-=bet;
}
system("pause");
n++;
goto re1;
end:
system("pause");
return 0;
}
複製代碼
作者:
戴安利
時間:
2019-1-5 16:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, money=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;
}else
{
cout<<"損失"<<bet<<"元!"<<endl;
money-=bet;
}
system("pause");
n++;
goto re;
end:
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2