註冊
登錄
論壇
搜索
幫助
導航
私人消息 (0)
公共消息 (0)
系統消息 (0)
好友消息 (0)
帖子消息 (0)
種子論壇 | 高雄市資訊培育協會學員討論區
»
結訓課程 (青少年程式設計班)
»
C++(六1330)(201709)
» 賽馬程式 (六)
返回列表
發帖
發短消息
加為好友
蕭澧邦
當前離線
UID
67747
帖子
364
精華
0
積分
0
閱讀權限
10
在線時間
75 小時
註冊時間
2016-7-7
最後登錄
2023-3-13
新手上路
1
#
跳轉到
»
蕭澧邦
發表於 2017-5-20 14:39
|
顯示全部帖子
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int win;
int num=1;
int balance=0;
int buyin;
int option;
int bet;
int players;
re:
system("cls");
int s[]={0,0,0,0};
string horse[]={"◆", "★", "▲", "●"};
cout<<"「好事成雙」賽馬場 第"<<num<<"局"<<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;
if(buyin<=0)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance+=buyin;
goto re;
}
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>>players;
if(players<=0 || players>4)
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
balance-=bet;
goto start;
}
else
{
cout<<"輸入錯誤!";
_sleep(1500);
goto re;
}
start:
cout<<"比賽即將開始..."<<endl<<endl;
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<<"◆"<<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;
win=r;
if(s[r]==73)
break;
_sleep(50);
}
system("cls");
cout<<"比賽結束! 由 "<<horse[win]<<" 勝出!"<<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(win==players)
{
balance+=bet*3;
}
else
{
cout<<"損失"<<bet<<"元!"<<endl;
}
system("pause");
num++;
goto re;
return 0;
}
複製代碼
TOP
返回列表
C++(一1900)(201808)
谷哥人營隊
Python研習營(113-114)
114年Python證照特訓
114年谷哥人程式體驗營
114年APCS冬令營
113Scratch夏令營
Scratch冬令營(113-114)
113年國三專班
Python證照特訓營(113)
113年程式夏令營(一)(二)
113年APCS夏令營(一)(二)
C語言 / C++ (特別輔導)
C++證照
C#
家教/特輔
C語言特輔/證照(家教)
C++證照
C#
HTML5+CSS+JavaScript+PHP+MySQL
Java 家教 (王捷恩)
TQC+資料結構
快樂學 Scratch
Python 家教 (王捷恩 康恒睿)
Python 特別輔導 (家教)
快樂 C++ (家教)
iKnow
我愛 Java (家教)
程式解題我最行 (家教)
程式常態班
C++ 新生挑戰區
考照心得分享
快樂 C++11307週五19:00
快樂C++11309週六13:30-15:30
快樂 C++11403週六1000
快樂 C++11303 (週六15:40-17:40) 3F
程式解題我最行 (週六15:30-17:30) 3F
快樂 C++ (週六13:30-15:30) 3F
快樂 C++ (週六19:00-21:00) 3F
程式解題我最行 (週六10:00-12:00) 3F
快樂學 Scratch
程式解題我最行(週五19:00-21:00)
快樂 C++ (週六13:30-15:30) 3F
程式解題我最行(週三19:15-21:15)
快樂 C++11207週六10
快樂 C++11208週六19:00
程式解題我最行 (週六19:00-21:00) 3F
程式解題我最行 (週四19:10-21:10)
產投職訓
結訓課程 (產投職訓)
Php & MySQL old
Illustrator old
Dreamweaver old
Android手機程式開發班
PHP & MySQL電子商務互動式網站實作班 (102下)
PHP & MySQL (102上)
PHP & MySQL電子商務互動式網站實作班
Photoshop數位影像設計初階
Flash創意廣告動畫初階
行銷短片視訊剪輯
數位商業攝影實務班
PHP & MySQL電子商務系統開發實務初階班
電子商務系統開發實務中階班
Server基礎架設&動態網頁設計初階班
Java視窗應用程式設計與遊戲開發班
Illustrator時尚插畫創作設計初階班
102上Php & MySQL 初階班
電子商務互動式網站實作中階
Dreamweaver多媒體網頁設計
Android手機程式開發班(2012年10月)
PHP & MySQL (2012年10月)
創意塗鴉
yahoo橫幅
google橫幅
市民學苑
第二屆樂活部落格
第一屆電腦設備簡易維護和故障排除班
專案訓練
電子商務創業班
TQC PHP認證
投資理財班
領隊導遊班
電腦基礎及網路應用身心障礙專班
應用軟體網頁化開發
[收藏此主題]
[關注此主題的新回復]
[通過 QQ、MSN 分享給朋友]