標題:
賽馬程式 (三)
[打印本頁]
作者:
周政輝
時間:
2018-5-12 13:51
標題:
賽馬程式 (三)
1. 在比賽首頁顯示第幾局
2. 在比賽結束頁顯示哪一位選手勝出
[attach]4053[/attach]
[attach]4054[/attach]
作者:
鄭楀諺
時間:
2018-5-12 13:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int h1=0;
int h2=0;
int h3=0;
int h4=0;
int random=0;
int round=1;
srand(time(NULL));
while(true)
{
cout<<"第"<<round<<"局"<<endl;
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"|-------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"(1)下注\t\t(2)錢包\t\t(3)";
system("pause");
while(h1!=75&&h2!=75&&h3!=75&&h4!=75)
{
random=rand()%4;
if(random==0)
{
h1++;
}
if(random==1)
{
h2++;
}
if(random==2)
{
h3++;
}
if(random==3)
{
h4++;
}
cout<<"比賽進行中"<<endl;
cout<<"|-------------------------------------------------------------------------|終點"<<endl;
for(int i=0;i<=h1;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=0;i<=h2;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0;i<=h3;i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=0;i<=h4;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
round++;
system("cls");
cout<<"比賽結束! 由";
if(h1==75)
{
cout<<"◆搶先得馳"<<endl;
}
if(h2==75)
{
cout<<"★搶先得馳"<<endl;
}
if(h3==75)
{
cout<<"▲搶先得馳"<<endl;
}
if(h4==75)
{
cout<<"●搶先得馳"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
吳秉翰
時間:
2018-5-12 14:18
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int h1=0, h2=0, h3=0, h4=0, random=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場" << "第 " <<times << "局 "<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(h1!=75 && h2!=75 && h3!=75 && h4!=75)
{
random=rand()%4;
if(random==0)
{
h1++;
}
else if(random==1)
{
h2++;
}
else if(random==2)
{
h3++;
}
else if(random==3)
{
h4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=h1; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=h2; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=h3; i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=h4; i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
if(h1==75)
{
cout<<"比賽結束,由◆先馳得點"<<endl;
}
else if(h2==75)
{
cout<<"比賽結束,由★先馳得點"<<endl;
}
else if(h3==75)
{
cout<<"比賽結束,由▲先馳得點"<<endl;
}
else if(h4==75)
{
cout<<"比賽結束,由●先馳得點"<<endl;
}
times++;
}
system("pause");
return 0;
}
複製代碼
作者:
湯東緯
時間:
2018-5-12 14:19
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0, random=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場 " << "第 " <<times << "局 "<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
{
random=rand()%4;
if(random==0) {
horse1++;
}
else if(random==1) {
horse2++;
}
else if(random==2){
horse3++;
}
else if(random==3) {
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++;
system("cls");
if(horse1==75)
{
cout<<"◆搶先得馳"<<endl;
}
if(horse2==75)
{
cout<<"★搶先得馳"<<endl;
}
if(horse3==75)
{
cout<<"▲搶先得馳"<<endl;
}
if(horse4==75)
{
cout<<"●搶先得馳"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
林峻安
時間:
2018-5-12 14:24
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int h1=0, h2=0, h3=0, h4=0, random=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<"第"<<times <<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"ω"<<endl;
cout<<"£"<<endl;
cout<<"Θ"<<endl;
cout<<"卍"<<endl;
system("pause");
system("cls");
while(h1!=75 && h2!=75 && h3!=75 && h4!=75)
{
random=rand()%4;
if(random==0) {
h1++;
}
else if(random==1) {
h2++;
}
else if(random==2) {
h3++;
}
else if(random==3) {
h4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=h1; i++) {
cout<<" ";
}
cout<<"ω"<<endl;
for(int i=1; i<=h2; i++) {
cout<<" ";
}
cout<<"£"<<endl;
for(int i=1; i<=h3; i++) {
cout<<" ";
}
cout<<"Θ"<<endl;
for(int i=1; i<=h4; i++) {
cout<<" ";
}
cout<<"卍"<<endl;
system("cls");
}
if(h1==75)
{
cout<<"由ω先馳得點"<<endl;
}
else if(h2==75)
{
cout<<"由£先馳得點"<<endl;
}
else if(h3==75)
{
cout<<"由Θ先馳得點"<<endl;
}
else if(h4==75)
{
cout<<"由卍先馳得點"<<endl;
}
times++;
}
system("pause");
return 0;
}
複製代碼
作者:
顏詢
時間:
2018-5-12 14:27
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int a1=0,a2=0,a3=0,a4=0,random=0;
int times=1 ;
srand(time(NULL));
while(true)
{
cout<<"「好事成雙」賽馬場 " << "第 " <<times << "局 "<<endl;
cout<<"-------------------------------------------------------------------------[終點"<<endl;
cout<<"●"<<endl;
cout<<"▼"<<endl;
cout<<"■"<<endl;
cout<<"★"<<endl;
system("pause");
while(a1!=75&&a2!=75&&a3!=75&&a4!=75)
{
random=rand()%4;
if(random==0) {
a1++;
}
else if(random==1)
{
a2++;
}
else if(random==2)
{
a3++;
}
else if(random==3)
{
a4++;
}
cout<<"「好事成雙」賽馬場"<<"第"<<times<<"局"<<endl;
cout<<"-------------------------------------------------------------[終點"<<endl;
for(int i=1; i<=a1; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=a2; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=a3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=a4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++ ;
system("cls");
if(a1==75)
{
cout<<"比賽結束 由:◆獲勝"<<endl;
}
else if(a2==75)
{
cout<<"比賽結束 由:★獲勝"<<endl;
}
else if(a3==75)
{
cout<<"比賽結束 由:▲獲勝"<<endl;
}
else if(a4==75)
{
cout<<"比賽結束 由:●獲勝"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
黃安立
時間:
2018-5-12 14:32
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0, random=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場 " << "第 " <<times << "局 "<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
{
random=rand()%4;
if(random==0) {
horse1++;
}
else if(random==1) {
horse2++;
}
else if(random==2) {
horse3++;
}
else if(random==3) {
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
system("cls");
cout<<"比賽結束,由:";
if(horse1==75)
{
cout<<"◆搶先得馳"<<endl;
}
else if(horse2==75)
{
cout<<"★搶先得馳"<<endl;
}
else if(horse3==75)
{
cout<<"●搶先得馳"<<endl;
}
else if(horse4==75)
{
cout<<"◆搶先得馳"<<endl;
}
times++;
}
system("pause");
return 0;
}
複製代碼
作者:
戴嘉禾
時間:
2018-5-12 15:27
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
re:
int times=0;
times++;
while(true)
{
int horse1=0,horse2=0,horse3=0,horse4=0;
int random=0,num=0,num1=0,num2=0,num3=0;
srand (time(NULL));
system("cls");
cout<<"☆★☆[嘉禾豬]賽馬場☆★☆"<<" 第"<<times<<"場"<<endl;
cout<<"========================================================|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"☆"<<endl;
cout<<"●"<<endl;
cout<<"=============================================================="<<endl;
cout<<" ★☆★ 遊戲規則 ★☆★ "<<endl;
cout<<"1.下注正確將會獲得五倍的錢!"<<endl;
cout<<"2.下注錯誤將會失去三倍的錢!"<<endl;
cout<<"請下注 => 代碼和下注金額:100元~50000000元)(1)◆ (2)★ (3)☆ (4)●"<<endl;
cout<<"代碼:";
cin>>num;
if(num<1||num>4)
{
cout<<"代碼錯誤!"<<endl;
system("pause");
goto re;
}
cout<<"下注金額:";
cin>>num1;
if(num1<100||num1>50000000)
{
cout<<"金額錯誤!"<<endl;
system("pause");
goto re;
}
cout<<"是否要反悔? (1)要 (2)不要"<<endl;
cin>>num3;
if(num3==1)
{
goto re;
}
else if(num3==2)
{
goto re5;
}
re5:
system("pause");
system("cls");
while(horse1!=75||horse2!=75||horse3!=75||horse4!=75)
{
random=rand()%4;
if(random==0)
{
horse1++;
}
else if(random==1)
{
horse2++;
}
else if(random==2)
{
horse3++;
}
else if(random==3)
{
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"========================================================|終點"<<endl;
for(int i=1;i<horse1;i++)
{
cout<<" ";
}cout<<"◆"<<endl;
for(int i=1;i<horse2;i++)
{
cout<<" ";
}cout<<"★"<<endl;
for(int i=1;i<horse3;i++)
{
cout<<" ";
}cout<<"☆"<<endl;
for(int i=1;i<horse4;i++)
{
cout<<" ";
}cout<<"●"<<endl;
system("cls");
if(horse1==60)
{
cout<<"比賽結束"<<endl;
cout<<"==========================================================|終點"<<endl;
for(int i=1;i<horse1;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<horse2;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<horse3;i++)
{
cout<<" ";
}
cout<<"☆"<<endl;
for(int i=1;i<horse4;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
cout<<"==========================================================|===="<<endl;
cout<<"你輸入的代碼:("<<num<<")"<<endl;
cout<<"你下注了"<<num1<<"元"<<endl;
cout<<"(1)◆贏了!"<<endl;
if(num==1)
{
cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
}
else if(num==2||num==3||num==4)
{
cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
}
re1:
cout<<"要再玩一次嗎? (1)要 (2)不要"<<endl;
cin>>num2;
if(num2==2)
{
system("cls");
cout<<"謝謝光臨!再見!"<<endl;
}
else if(num2==1)
{
times++;
break;
}
else if(num2<1||num2>2)
{
cout<<"輸入錯誤"<<endl;
goto re1;
}
system("pause");
if(num2==1)
{
continue;
}
else
{
break;
}
}
if(horse2==60)
{
cout<<"比賽結束"<<endl;
cout<<"==========================================================|終點"<<endl;
for(int i=1;i<horse1;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<horse2;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<horse3;i++)
{
cout<<" ";
}
cout<<"☆"<<endl;
for(int i=1;i<horse4;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
cout<<"==========================================================|===="<<endl;
cout<<"你輸入的代碼:("<<num<<")"<<endl;
cout<<"你下注了"<<num1<<"元"<<endl;
cout<<"(2)★贏了!"<<endl;
if(num==2)
{
cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
}
else if(num==1||num==3||num==4)
{
cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
}
re2:
cout<<"要再玩一次嗎? (1)要 (2)不要"<<endl;
cin>>num2;
if(num2==2)
{
system("cls");
cout<<"謝謝光臨!再見!"<<endl;
}
else if(num2==1)
{
times++;
break;
}
else if(num2<1||num2>2)
{
cout<<"輸入錯誤"<<endl;
goto re2;
}
system("pause");
if(num2==1)
{
continue;
}
else
{
break;
}
}
if(horse3==60)
{
cout<<"比賽結束"<<endl;
cout<<"==========================================================|終點"<<endl;
for(int i=1;i<horse1;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<horse2;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<horse3;i++)
{
cout<<" ";
}
cout<<"☆"<<endl;
for(int i=1;i<horse4;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
cout<<"==========================================================|===="<<endl;
cout<<"你輸入的代碼:("<<num<<")"<<endl;
cout<<"你下注了"<<num1<<"元"<<endl;
cout<<"(3)☆贏了!"<<endl;
if(num==3)
{
cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
}
else if(num==1||num==2||num==4)
{
cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
}
re3:
cout<<"要再玩一次嗎? (1)要 (2)不要"<<endl;
cin>>num2;
if(num2==2)
{
system("cls");
cout<<"謝謝光臨!再見!"<<endl;
}
else if(num2==1)
{
times++;
break;
}
else if(num2<1||num2>2)
{
cout<<"輸入錯誤"<<endl;
goto re3;
}
system("pause");
if(num2==1)
{
continue;
}
else
{
break;
}
}
if(horse4==60)
{
cout<<"比賽結束"<<endl;
cout<<"==========================================================|終點"<<endl;
for(int i=1;i<horse1;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<horse2;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<horse3;i++)
{
cout<<" ";
}
cout<<"☆"<<endl;
for(int i=1;i<horse4;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
cout<<"==========================================================|===="<<endl;
cout<<"你輸入的代碼:("<<num<<")"<<endl;
cout<<"你下注了"<<num1<<"元"<<endl;
cout<<"(4)●贏了!"<<endl;
if(num==4)
{
cout<<"恭喜你!你獲得了"<<num1*5<<"元"<<endl;
}
else if(num==1||num==2||num==3)
{
cout<<"真可惜!你失去了"<<num1*3<<"元"<<endl;
}
re4:
cout<<"要再玩一次嗎? (1)要 (2)不要"<<endl;
cin>>num2;
if(num2==2)
{
system("cls");
cout<<"謝謝光臨!再見!"<<endl;
}
else if(num2==1)
{
times++;
break;
}
else if(num2<1||num2>2)
{
cout<<"輸入錯誤"<<endl;
goto re4;
}
system("pause");
if(num2==1)
{
continue;
}
else
{
times++;
break;
}
}
if(num2==2)
{
break;
}
}
if(num2==2)
{
break;
}
}
return 0;
}
複製代碼
作者:
王駿愷
時間:
2018-5-26 13:09
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=0;
while(true)
{
int h1=0,h2=0,h3=0,h4=0,random=0,round=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<"第"<<times<<"局"<<endl;
cout<<"---------------------------------------------------------------------[終點"<<endl;
cout<<"●"<<endl;
cout<<"▼"<<endl;
cout<<"■"<<endl;
cout<<"★"<<endl;
system("pause") ;
while(h1!=75&&h2!=75&&h3!=75&&h4!=75)
{
random=rand()%4;
if(random==0) {
h1++;
}
else if(random==1)
{
h2++;
}
else if(random==2)
{
h3++;
}
else if(random==3)
{
h4++;
}
cout<<"比賽進行中"<<endl;
cout<<"---------------------------------------------------------------------[終點"<<endl;
for(int i=1; i<=h1; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=h2; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=h3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=h4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++;
system("cls");
if(h1==75)
{
cout<<"比賽結束由◆先馳得點"<<endl;
}
if(h2==75)
{
cout<<"比賽結束由★先馳得點"<<endl;
}
if(h3==75)
{
cout<<"比賽結束由★先馳得點"<<endl;
}
if(h4==75)
{
cout<<"比賽結束由●先馳得點"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2