標題:
賽馬程式 (四)
[打印本頁]
作者:
鄭繼威
時間:
2023-3-18 12:11
標題:
賽馬程式 (四)
加入首頁選單, 新增
買入
(儲值)
的功能, 執行畫面如下:
(1)買入
(2)下注 (3)離開 請選擇:
在使用者輸入數值後, 畫面更新如下:
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1; //局數
int balance=0; //餘額
int option; //選項
int buy; //儲值金額
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0}; //存放進度用的
string p[]={"◆","★","▲","●"}; //存放馬用的
int r=0;
cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<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;
//輸入等於1執行買入(儲值)
if(option==1){
//買入
cout<<"買入: ";
cin>>buy;
balance=balance+buy; //儲值
goto re;
}
system("pause");
system("cls"); //清空畫面
while(s[r]<=73) //開始賽馬
{
r=rand()%4; //0~3 (抽馬)
s[r]++; //看電腦抽到哪隻馬就+1
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");
round++; //局數+1
goto re;
return 0;
}
複製代碼
作者:
陳宥霖
時間:
2023-3-18 14:50
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"「好事成雙」賽馬場"<<"第"<<round<<"場"<<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>>buy;
balance=balance+buy;
goto re;
}
system("pause");
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");
round++;
goto re;
return 0;
}
複製代碼
作者:
羅暐傑
時間:
2023-3-18 14:52
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
int round=1;
int balance=0;
int money=0;
re:
system("cls");
srand(time(NULL));
string p[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r=0;
int choice;
cout<<"歡迎光臨騙你錢賽馬場 | 賽馬第"<<round<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<p[i]<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入(儲值) (2)下注 (3)離開 請選擇:";
cin>>choice;
if(choice==1){
cout<<"請問要加值多少錢:";
cin>>money;
balance=balance+money;
goto re;
}
system("pause");
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;
}
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;
}
round++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
楊芊琦
時間:
2023-3-18 14:52
using namespace std;
int main()
{
int round = 1;
int buy=0,balance=0,option;
srand(time(NULL));
string shape[] = { "◆","★","▲","●" };
re:
cout<<"你的餘額:"<<balance<<endl;
cout<<"買入<1> 下注<2> 不玩了<3>"<<endl;
cin>>option;
if(option=1)
{
cout<<"輸入金額:";
cin>>buy;
balance+=buy;
goto re;
}
else
cout<<"已退出遊戲,你的餘額為:"<<balance<<endl;
int steps[] = {0,0,0,0};
cout<<"第"<<round<<"局"<<endl;
cout << "超坑錢賽馬場" << endl;
cout << "-------------------------------------------------------------------------|終點";
_sleep(2000);
int w = 0;int plus;
while (w <= 71)
{
cout << "比賽進行中" << endl;
cout << "-------------------------------------------------------------------------|終點" << endl;
steps[rand() % 4] += 1;
w = steps[rand() % 4];
for (int s = 0;s <= steps[0];s++)
cout << " ";
cout << shape[0] << endl;
for (int s = 0;s <= steps[1];s++)
cout << " ";
cout << shape[1] << endl;;
for (int s = 0;s <= steps[2];s++)
cout << " ";
cout << shape[2] << endl;
for (int s = 0;s <= steps[3];s++)
cout << " ";
cout << shape[3] << endl;
_sleep(10);
if (w ==71)
{
round++;
cout<<"由"<<shape[rand() % 4]<<"獲勝" <<endl;
_sleep(1000);
system("pause");
goto re;
}
system("cls");
}
}
複製代碼
作者:
吳俊頡
時間:
2023-3-18 14:53
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"豬","馬","牛","羊"};
int r=0;
cout<<"可憐啊!賽馬場 第"<<round<<"局"<<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<<buy;
balance=balance+buy;
goto re;
system("pause");
system("cls");
while(s[r]<=73)
{
r=rand()%4;
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");
round++;
goto re;
return 0;
}
複製代碼
作者:
羅紹齊
時間:
2023-3-18 14:54
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<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>>buy;
balance=balance+buy;
goto re;
}
system("pause");
system("cls");
while(s[r]<=73){
r=rand()%4;
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(1);
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");
round++;
goto re;
return 0;
}
複製代碼
作者:
宜儒
時間:
2023-3-18 14:55
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
int round=1; //局數
int balance=0; //可用餘額
int option; //選項
int buy; //買入
srand(time(NULL));
re:
system("cls");
int r=0; //0~3
string p[]={"◆","★","▲","●"}; //存放馬
int s[]={0,0,0,0}; //每匹馬左側的空白數
cout<<"好事成雙賽馬場 第"<<round<<"局"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
for(int i=0;i<=3;i++)
cout<<p[i]<<endl;
cout<<"可用餘額:"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1){
cout<<"買入:";
cin>>buy;
balance+=buy;
goto re;
}
system("pause");
while(s[r]<70){ //只要有任何一匹馬到達終點,迴圈就會停下來
r=rand()%4; //r=0~3
s[r]++;
system("cls");
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
for(int j=0;j<=3;j++){
for(int i=0;i<s[j];i++)
cout<<" ";
cout<<p[j]<<endl;
}
_sleep(10);
}
system("cls");
cout<<"比賽結束! 由"<<p[r]<<"勝出!"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
for(int j=0;j<=3;j++){
for(int i=0;i<s[j];i++)
cout<<" ";
cout<<p[j]<<endl;
}
system("pause");
round++; //局數+1
goto re;
return 0;
}
複製代碼
作者:
陳牧謙
時間:
2023-3-18 14:56
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"赤兔","的盧","照獅","絕影"};
int r=0;
cout<<"「壞事成三」賽馬場(照夜玉獅子) 第"<<round<<"局"<<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>>buy;
balance=balance+buy;
goto re;
}
system("cls");
while(s[r]<=73)
{
r=rand()%4;
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(1);
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");
round++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
鄭繼威
時間:
2023-3-18 14:57
7
作者:
徐啟祐
時間:
2023-3-18 14:58
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1,balance=0,option,buy;
re:
system("cls");
srand(time(NULL));
string p[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r=0;
cout<<"「好事成霜」賽馬場 第"<<round<<"局"<<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<<endl<<"買入: ";
cin>>buy;
balance=balance+buy;
goto re;
}
system("pause");
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(10);
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");
round++;
goto re;
return 0;
}
複製代碼
作者:
林雋喆
時間:
2023-3-18 14:59
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<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>>buy;
balance=balance+buy;
}
system("pause");
system("cls");
while(s[r]<=73)
{
r=rand()%4;
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(5);
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");
round++;
goto re;
return 0;
}
複製代碼
作者:
陳泓亦
時間:
2023-3-18 14:59
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<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>>buy;
balance=balance+buy;
goto re;
}
system("pause");
system("cls");
while(s[r]<=73)
{
r=rand()%4;
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");
round++;
goto re;
return 0;
}
複製代碼
作者:
楊芊琦
時間:
2023-3-18 15:31
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round = 1;
int buy=0,play,balance=0,option,player;
srand(time(NULL));
string shape[] = { "◆","★","▲","●" };
re:
cout<<"你的餘額:"<<balance<<endl;
cout<<"買入<1> 下注<2> 不玩了<3>"<<endl;
cin>>option;
if(option==1)
{
cout<<"輸入金額:";
cin>>buy;
if(buy<=0)
{
cout<<"輸入錯誤"<<endl;
_sleep(1500);
system("cls");
goto re;
}
balance+=buy;
buy=0;
goto re;
}
else if(option==2)
{
cout<<"下注金額:";
cin>>buy;
play+=buy;
balance-=buy;
if(buy<=0)
{
cout<<"餘額不足"<<endl;
_sleep(1500);
system("cls");
goto re;
}
if(buy<=0)
{
cout<<"輸入錯誤"<<endl;
_sleep(1500);
system("cls");
goto re;
}
cout<<"請選擇馬匹:◆<1>★<2>▲<3>●<4>";
cin>>player;
}
else
{
cout<<"已退出遊戲,你的餘額為:"<<balance<<endl;
_sleep(3000);
return 0;
}
int steps[] = {0,0,0,0};
cout<<"第"<<round<<"局"<<endl;
cout << "超坑錢賽馬場" << endl;
cout << "-------------------------------------------------------------------------|終點";
_sleep(2000);
int w = 0;int plus;
while (w <= 71)
{
cout << "比賽進行中" << endl;
cout << "-------------------------------------------------------------------------|終點" << endl;
steps[rand() % 4] += 1;
w = steps[rand() % 4];
for (int s = 0;s <= steps[0];s++)
cout << " ";
cout << shape[0] << endl;
for (int s = 0;s <= steps[1];s++)
cout << " ";
cout << shape[1] << endl;;
for (int s = 0;s <= steps[2];s++)
cout << " ";
cout << shape[2] << endl;
for (int s = 0;s <= steps[3];s++)
cout << " ";
cout << shape[3] << endl;
_sleep(10);
if (w ==71)
{
round++;
cout<<"由"<<shape[rand() % 4]<<"獲勝" <<endl;
_sleep(1000);
if((rand()%4)+1==player)
{
balance+=buy*100;
system("pause");
goto re;
}
cout<<"什麼?你沒有賭注他?"<<endl;
buy==0;
goto re;
}
system("cls");
}
}
複製代碼
作者:
翁川祐
時間:
2023-3-24 19:28
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int round=1;
int balance=0;
int option;
int buy;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<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>>buy;
balance=balance+buy;
goto re;
}
system("pause");
system("cls");
while(s[r]<=73)
{
r=rand()%4;
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(25);
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");
round++;
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2