標題:
賽馬程式 (四)
[打印本頁]
作者:
陳品肇
時間:
2018-12-15 00:24
標題:
賽馬程式 (四)
加入首頁選單, 新增買入的功能, 執行畫面如下:
可用餘額: 0 元
(1)買入 (2)下注 (3)離開 請選擇: 1
買入: 200
在使用者輸入數值後, 畫面更新如下:
可用餘額: 200 元
(1)買入 (2)下注 (3)離開 請選擇:
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0;
re1:
int a=0, b=0, c=0, d=0, r, option, buyin;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin; //balance=balance+buyin
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4; //產生0~3之隨機亂數
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2018-12-15 16:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,money=0;
re:
int a=0, b=0, c=0, d=0, r, option, buy;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額: "<<money<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buy;
money+=buy;
goto re;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4; //產生0~3之隨機亂數
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
n++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
陳柏霖
時間:
2018-12-15 16:45
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=1 ,mony=0 ,many;
re:
int a=0 ,b=0 ,c=0 ,d=0 ,z;
string n[]={"◆","★","㊣","▼"};
srand(time(NULL));
cout<<"第"<<x<<"場[萬事如意]賽馬場"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"㊣"<<endl;
cout<<"▼"<<endl<<endl;
cout<<"可用餘額:"<<mony<<"元"<<endl;
cout<<"(1)買入(2)下注(3)離開 請選擇:";
cin>>many;
if(many==1)
{
int tim;
cout<<"買入:";
cin>>tim;
mony=mony+tim;
system("cls");
goto re;
}else
{
cout<<"輸入錯誤";
system("cls");
goto re;
}
system("pause");
while(a!=70 && b!=70 && c!=70 && d!=70)
{
cout<<"比賽中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
z=rand()%4+1;
if(z==1)
{
a+=2;
}
if(z==2)
{
b+=2;
}
if(z==3)
{
c+=2;
}
if(z==4)
{
d+=2;
}
for(int i=0; i<=a; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0; i<=b; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0; i<=c; i++)
{
cout<<" ";
}
cout<<"㊣"<<endl;
for(int i=0; i<=d; i++)
{
cout<<" ";
}
cout<<"▼"<<endl;
system("cls");
}
cout<<"第"<<x<<"場比賽結束 由"<<n[z-1]<<"先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=a; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0; i<=b; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0; i<=c; i++)
{
cout<<" ";
}
cout<<"㊣"<<endl;
for(int i=0; i<=d; i++)
{
cout<<" ";
}
cout<<"▼"<<endl;
cout<<"按任意鍵進行下一場比賽"<<endl;
system("pause");
system("cls");
x++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
戴唯陞
時間:
2018-12-15 16:47
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0;
re1:
int a=0, b=0, c=0, d=0, r,option,buy;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"剩餘金額"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 選擇:"<<endl;
cin>>option;
if(option==1)
{
cout<<"買入"<<endl;
cin>>buy;
balance+=buy;
goto re1;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=60 && b!=60 && c!=60 && d!=60)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束";
if(a==60)
cout<<"◆";
else if(b==60)
cout<<"★";
else if(c==60)
cout<<"▲";
else
cout<<"●";
cout<<" 先到了!"<<endl;
cout<<"--------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2018-12-15 16:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int balance=0;
start:
srand(time(NULL));
int space[]={0,0,0,0};
int option, money;
system("cls");
cout<<"賽馬場"<<endl;
cout<<"------------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if (option==1)
{ cout<<"買入: ";
cin>>money;
balance+=money; //balance=balance+buyin
goto start;
}
system("pause");
while (true)
{
int r=rand()%4;
space[r]++;
if(space[r]==74)
break;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=space[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int j=0;j<=space[1]; j++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int j=0;j<=space[2];j++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int j=0;j<=space[3];j++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(space[0]==74)
cout<<"◆";
else if(space[1]==74)
cout<<"★";
else if(space[2]==74)
cout<<"▲";
else
cout<<"●";
cout<<" 先到達終點!"<<endl;
cout<<"比賽結束"<<endl;
cout<<"--------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=space[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int j=0;j<=space[1]; j++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int j=0;j<=space[2];j++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int j=0;j<=space[3];j++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("pause");
goto start;
system("pause");
return 0;
}
複製代碼
作者:
戴安利
時間:
2018-12-15 16:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1, money=0;
re:
int a=0, b=0, c=0, d=0, r, option, buyin;
system("cls");
cout<<"+++好事成雙->賽馬場+++ 第"<<n<<"局"<<endl;
cout<<"-------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<money<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開"<<endl;
cin>>option;
if(option==1)
{
cout<<"買入:"<<endl;
cin>>buyin;
money+=buyin;
goto re;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=20 && b!=20 && c!=20 && d!=20)
{
cout<<"賽馬進行中..."<<endl;
cout<<"-------------------------------------------|終點"<<endl;
r = rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==4)
d++;
for(int i=0;i<=a;i++)
cout<<" ";
cout<<"◆"<<endl;
a++;
for(int i=0;i<=b;i++)
cout<<" ";
cout<<"★"<<endl;
b++;
for(int i=0;i<=c;i++)
cout<<" ";
cout<<"▲"<<endl;
c++;
for(int i=0;i<=d;i++)
cout<<" ";
cout<<"●"<<endl;
d++;
system("cls");
}
cout<<"賽馬結束...!由 ";
if(a==20)
cout<<"◆";
else if(b==20)
cout<<"★";
else if(c==20)
cout<<"▲";
else
cout<<"●";
cout<<"先抵達終點!"<<endl;
cout<<"-------------------------------------------|終點"<<endl;
for(int i=0;i<=a;i++)
cout<<" ";
cout<<"◆"<<endl;
a++;
for(int i=0;i<=b;i++)
cout<<" ";
cout<<"★"<<endl;
b++;
for(int i=0;i<=c;i++)
cout<<" ";
cout<<"▲"<<endl;
c++;
for(int i=0;i<=d;i++)
cout<<" ";
cout<<"●"<<endl;
d++;
system("pause");
n++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
蔡季庭
時間:
2018-12-15 16:51
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1 , money=0;
re1:
int r,option,buyin;
int space[4]={0,0,0,0};
string name[4]={"◆","★","▲","●"};
srand(time(NULL));
system("cls");
cout<<"[好棒棒]賭賽馬場"<<"第"<<n<<"局"<<endl;
cout<<"-------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"可用餘額"<<money<<"元"<<endl<<endl;
cout<<"(1)買入(2)下注(3)滾 ㊣㊣㊣ 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
money=money+buyin;
goto re1;
}
system("pause");
while(true)
{
r=rand()%4;
space[r]++;
if(space[r]==34)
break;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int j=0;j<space[0];j++)
cout<<" ";
cout<<"◆"<<endl;
for(int j=0;j<space[1];j++)
cout<<" ";
cout<<"★"<<endl;
for(int j=0;j<space[2];j++)
cout<<" ";
cout<<"▲"<<endl;
for(int j=0;j<space[3];j++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束"<<endl;
cout<<"----------------------------------|終點"<<"由"<<name[r]<<"先馳得點"<<endl;
for(int j=0;j<space[0];j++)
cout<<" ";
cout<<"◆"<<endl;
for(int j=0;j<space[1];j++)
cout<<" ";
cout<<"★"<<endl;
for(int j=0;j<space[2];j++)
cout<<" ";
cout<<"▲"<<endl;
for(int j=0;j<space[3];j++)
cout<<" ";
cout<<"●"<<endl;
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
戴偉宸
時間:
2018-12-15 17:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1,balance=0;
re:
int a=0,b=0,c=0,d=0,r,option,buyin;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
balance+=buyin;
goto re;
}
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70&& d!=70)
{
cout<<"賽馬進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==4)
d++;
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
cout<<"賽馬結束"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"由";
if(a==70)
{
cout<<"◆";
}
else if(b==70)
{
cout<<"★";
}
else if(c==70)
{
cout<<"▲";
}
else if(d==70)
{
cout<<"●";
}
cout<<"先馳得點"<<endl<<endl;
system("pause");
system("cls");
n++ ;
goto re;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2