標題:
賽馬程式 (四)
[打印本頁]
作者:
方浩葦
時間:
2024-7-27 11:16
標題:
賽馬程式 (四)
加入首頁選單, 新增買入的功能, 執行畫面如下:
在使用者輸入數值後, 畫面更新如下:
本帖隱藏的內容需要回復才可以瀏覽
作者:
林少謙
時間:
2024-7-27 15:19
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int x,y,z,sum=0,money,money2;
int a[]{0,0,0,0};
string b[]{"◆","★","▲","●"};
re2:
system("cls");
cout<<"空蕩蕩賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
cout<<"<1>買入 <2>下注 <3>離開 請選擇:";
cin>>z;
if(z==1)
{
cout<<"買入: ";
cin>>money;
sum+=money;
goto re2;
}
system("pause");
re:
if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
{
system("cls");
cout<<"比賽開始"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=3; i++)
{
x=rand()%5+1;
a[i]+=x;
}
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(100);
goto re;
}
else
{
if(a[0]>=73)
y=0;
if(a[1]>=73)
y=1;
if(a[2]>=73)
y=2;
if(a[3]>=73)
y=3;
system("cls");
cout<<"比賽結束由"<<b[y]<<"獲勝"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李唯銘
時間:
2024-7-27 16:26
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1,money=0;
re:
system("cls");
int a=0, b=0, c=0, d=0,sum,choose;
srand(time(NULL));
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"可用餘額:"<<money<<endl;
cout<<"(1)買入 (2)下注 (3)離開"<<endl;
cin>>choose;
if(choose==1){
cout<<"金額"<<endl;
cin>>sum;
money+=sum;
goto re;
}
system("pause");
while(true){
system("cls");
cout<<"比賽中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;\
int r=rand()%4;
if(r==0){
a++;
}
else if(r==1){
b++;
}
else if(r==2){
c++;
}
else if(r==3){
d++;
}
for(int i=1; i<=a; i++){
cout<<" ";}
cout<<"◆"<<endl;
for(int j=1; j<=b; j++){
cout<<" ";}
cout<<"★"<<endl;
for(int k=1; k<=c; k++){
cout<<" ";}
cout<<"▲"<<endl;
for(int l=1; l<=d; l++){
cout<<" ";}
cout<<"●"<<endl;
_sleep(50);
if((a==73)||(b==73)||(c==73)||(d==73))
break;
}
system("cls");
if(a==73){
cout<<"比賽結束,由◆先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
if(b==73){
cout<<"比賽結束,由★先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
if(c==73){
cout<<"比賽結束,由▲先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
if(d==73){
cout<<"比賽結束,由●先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
for(int i=1; i<=a; i++){
cout<<" ";}
cout<<"◆"<<endl;
for(int j=1; j<=b; j++){
cout<<" ";}
cout<<"★"<<endl;
for(int k=1; k<=c; k++){
cout<<" ";}
cout<<"▲"<<endl;
for(int l=1; l<=d; l++){
cout<<" ";}
cout<<"●"<<endl;
n++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
劉奕劭
時間:
2024-7-27 16:26
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int t=1;
int s,sum,v,money=0;
re1:
srand(time(NULL));
cout<<"賽馬場 第"<<t<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
int a[]{0,0,0,0};
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
re2:
cout<<"可用餘額:"<<sum<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>v;
if(v==1)
{
cout<<"買入: ";
cin>>money;
sum+=money;
}
system("pause");
cout<<"比賽開始"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
re:
if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73){
system("cls");
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
s=rand()%4;
a[s]++;
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(1);
goto re;
}else{
system("cls");
if(a[0]>=73){
cout<<"比賽結束,最終由◆勝出!!!"<<endl;
}else if(a[1]>=73){
cout<<"比賽結束,最終由★勝出!!!"<<endl;
}else if(a[2]>=73){
cout<<"比賽結束,最終由▲勝出!!!"<<endl;
}else if(a[3]>=73){
cout<<"比賽結束,最終由●勝出!!!"<<endl;
}
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
t++;
system("pause");
goto re1;
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-7-28 12:26
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1;
int money=0, x, money2;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
{
cout<<"可用餘額:"<<money<<"元"<<endl<<endl;
cout<<"<1>買入 <2>下注 <3>離開 請選擇:";
cin>>x;
if(x==1)
cout<<"買入: ";
cin>>money2;
money+=money2;
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;
system("pause");
n++;
goto re;
return 0;
}
複製代碼
作者:
陳妍蓁
時間:
2024-8-1 22:18
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int m1=0,m2=0;
int x=1;
re:
srand(time(NULL));
int n[]={0,0,0,0};
cout<<"「好事成雙」賽馬場第"<<x<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
string y[]={"◆","★","▲","●"};
cout<<endl<<endl;
cout<<"可用餘額: "<<m1<<"元"<<endl;
int option;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:"<<endl;
cin>>option;
if(option==1){
cout<<"買入:";
cin>>m2;
cout<<m2<<"元"<<endl;
m1+=m2;
}
else if(option==2){
}
for(int i=0;i<=3;i++)
cout<<y[i]<<endl;
int r=0;
system("pause");
while(true){
system("cls");
r=rand()%4;
n[r]++;
cout<<"比賽進行中,第"<<x<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=n[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0;i<=n[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0;i<=n[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0;i<=n[3];i++)
cout<<" ";
cout<<"●"<<endl;
if(n[r]==73)
break;
_sleep(1);
}system("cls");
cout<<"比賽結束由"<<y[r]<<"先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=n[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0;i<=n[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0;i<=n[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0;i<=n[3];i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
x++;
system("cls");
goto re;
return 0;
}
複製代碼
作者:
李偈睿
時間:
2024-8-10 15:37
#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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2