註冊
登錄
論壇
搜索
幫助
導航
私人消息 (0)
公共消息 (0)
系統消息 (0)
好友消息 (0)
帖子消息 (0)
種子論壇 | 高雄市資訊培育協會學員討論區
»
113年國三專班
» [作業] 賽馬程式 (七)
返回列表
發帖
發短消息
加為好友
洪榮辰
當前離線
UID
69290
帖子
171
精華
0
積分
0
閱讀權限
10
在線時間
52 小時
註冊時間
2024-5-20
最後登錄
2025-3-8
新手上路
1
#
跳轉到
»
洪榮辰
發表於 2024-8-4 11:36
|
顯示全部帖子
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int a=1;
int balance=0, x, money, money2, n;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<a<<" 局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
{
cout<<"可用餘額:"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>x;
if(x==1)
{
cout<<"買入: ";
cin>>money;
balance+=money;
system("cls");
goto re;
}
else if(x==2)
{
cout<<"下注: ";
cin>>money2;
if(money2>balance)
{
cout<<"輸入錯誤"<<endl;
system("pause");
system("cls");
goto re;
}
cout<<endl;
cout<<"(1)◆ (2)★ (3)▲ (4)● 請選擇:";
cin>>n;
if(n>4)
{
cout<<"輸入錯誤"<<endl;
system("pause");
system("cls");
goto re;
}
else
{
cout<<"比賽即將開始..."<<endl<<endl;
system("pause");
}
}
else if(x==3)
{
if(balance>0)
{
cout<<"恭喜你!這次總共贏了"<<balance<<"元!"<<endl<<endl;
}
else if(balance<0)
{
cout<<"不好意思!讓你損失了"<<-balance<<"元!"<<endl<<endl;
}
else
{
cout<<"沒輸沒贏!全身而退!"<<endl<<endl;
}
system("pause");
return 0;
}
else
{
cout<<"輸入錯誤"<<endl;
system("pause");
system("cls");
goto re;
}
}
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;
if(s[r]==73)
break;
_sleep(0.00000001);
}
system("cls");
cout<<"比賽結束 ";
if(s[0]==73)
cout<<"由◆先馳得點!"<<endl;
if(s[1]==73)
cout<<"由★先馳得點!"<<endl;
if(s[2]==73)
cout<<"由▲先馳得點!"<<endl;
if(s[3]==73)
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(n==s[0])
{
cout<<"贏得"<<money2*3<<"元"<<endl;
balance+=money2*3;
}
if(n==s[1])
{
cout<<"贏得"<<money2*3<<"元"<<endl;
balance+=money2*3;
}
if(n==s[2])
{
cout<<"贏得"<<money2*3<<"元"<<endl;
balance+=money2*3;
}
if(n==s[3])
{
cout<<"贏得"<<money2*3<<"元"<<endl;
balance+=money2*3;
}
else
{
cout<<"損失"<<money2<<"元"<<endl;
balance-=money2;
}
system("pause");
a++;
goto re;
return 0;
}
複製代碼
TOP
返回列表
Python證照特訓營(113)
113年APCS冬令營
谷哥人營隊
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 家教 (王捷恩)
113新版塊名稱
快樂學 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 分享給朋友]