標題:
賽馬程式 (四)
[打印本頁]
作者:
鄭繼威
時間:
2023-1-4 21:15
標題:
賽馬程式 (四)
本帖最後由 鄭繼威 於 2023-3-4 20:57 編輯
加入首頁選單, 新增
買入
(儲值)
的功能, 執行畫面如下:
(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-1-11 20:16
#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-1-11 20:16
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int r=0, n=1, b, buy, option;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
cout<<p[i]<<endl;
}
cout<<"餘額"<<b<<"元"<<endl;
cout<<"(1)儲值(2)下注(3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"儲值:";
cin>>buy;
b=b+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;
}
n++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
連翊恩
時間:
2023-1-11 20:20
#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-1-11 20:21
#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-1-17 21: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(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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2