標題:
賽馬程式 (四)
[打印本頁]
作者:
李知易
時間:
2025-1-9 21:42
標題:
賽馬程式 (四)
本帖最後由 李知易 於 2025-1-17 18:58 編輯
加入首頁選單, 新增買入的功能, 執行畫面如下:
在使用者輸入數值後, 畫面更新如下:
[attach]20420[/attach][attach]20421[/attach][attach]20422[/attach]
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1, balance=0;
int option, buyin;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<p[i]<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
goto re;
}
system("cls");
while(s[r]<=73)
{
r=rand()%4; //0~3
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
_sleep(50);
system("cls");
}
cout<<"比賽結束! 由 "<<p[r]<<" 先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
system("pause");
n++;
goto re;
return 0;
}
複製代碼
作者:
張詠博
時間:
2025-1-12 08:43
此帖僅作者可見
作者:
彭郁程
時間:
2025-1-17 19:03
此帖僅作者可見
作者:
楊昀瑾
時間:
2025-1-17 19:03
此帖僅作者可見
作者:
朱立人
時間:
2025-1-17 19:06
此帖僅作者可見
作者:
洪睿輿
時間:
2025-1-17 19:13
此帖僅作者可見
作者:
吳孟樵
時間:
2025-1-17 19:14
此帖僅作者可見
作者:
江立辰
時間:
2025-1-17 19:14
此帖僅作者可見
作者:
鄭子宸
時間:
2025-1-17 19:31
此帖僅作者可見
作者:
陳頎諠
時間:
2025-1-17 19:34
此帖僅作者可見
作者:
黃品錡
時間:
2025-1-17 19:44
此帖僅作者可見
作者:
陳婕愉
時間:
2025-1-17 19:48
此帖僅作者可見
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2