標題:
賽馬程式 (二)
[打印本頁]
作者:
周政輝
時間:
2018-5-5 14:57
標題:
賽馬程式 (二)
請讓每一匹賽馬能動起來
本帖隱藏的內容需要回復才可以瀏覽
作者:
王駿愷
時間:
2018-5-5 15:13
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int h1=0,h2=0,h3=0,h4=0,random=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------[終點"<<endl;
cout<<"●"<<endl;
cout<<"▼"<<endl;
cout<<"■"<<endl;
cout<<"★"<<endl;
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");
}
system("pause");
return 0;
}
複製代碼
作者:
林峻安
時間:
2018-5-5 15:22
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main()
{
int h1=0,h2=0,h3=0,h4=0;
srand(time(NULL));
int random=0;
cout<<"「賽馬場」"<<endl;
cout<<"|--------------------------------------------------------------------------|終點"<<endl;
cout<<"ω"<<endl;
cout<<"£"<<endl;
cout<<"Θ"<<endl;
cout<<"卍"<<endl;
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");
}
system("pause");
return 0;
}
複製代碼
作者:
戴嘉禾
時間:
2018-5-5 15:30
本帖最後由 戴嘉禾 於 2018-5-8 22:38 編輯
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
re:
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<<"☆★☆[嘉禾豬]賽馬場☆★☆"<<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)
{
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)
{
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)
{
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)
{
break;
}
else if(num2<1||num2>2)
{
cout<<"輸入錯誤"<<endl;
goto re4;
}
system("pause");
if(num2==1)
{
continue;
}
else
{
break;
}
}
system("cls");
if(num2==2)
{
break;
}
}
if(num2==2)
{
break;
}
}
return 0;
}
複製代碼
作者:
黃安立
時間:
2018-5-5 15:30
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main()
{
int h1=0,h2=0,h3=0,h4=0;
srand(time(NULL));
int random=0;
cout<<"「賽馬場」"<<endl;
cout<<"|--------------------------------------------------------------------------|終點"<<endl;
cout<<"0"<<endl;
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
while(houres1!=75 && houres2!=75 && houres3!=75 && houres4!=75)
{ random=rand()%4;
if(random==0)
{ houres1++;
}
else if(random==1)
{ houres2++;
}
else if(random==2)
{ houres3++;
}
else if(random==3)
{ houres4++;
}
cout<<"比賽開始"<<endl;
cout<<"|----------------------------------------------------------------------------|終點"<<endl;
for(int i=1; i<=h1; i++)
{
cout<<" ";
}
cout<<"2"<<endl;
for(int i=1; i<=h2; i++)
{
cout<<" ";
}
cout<<"3"<<endl;
for(int i=1; i<=h3; i++)
{
cout<<" ";
}
cout<<"4"<<endl;
for(int i=1; i<=h4; i++)
{
cout<<" ";
}
cout<<"3"<<endl;
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
吳秉翰
時間:
2018-5-5 15:31
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int h1=0,h2=0,h3=0,h4=0;
srand(time(NULL));
int random;
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<=h1;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<=h1;i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1;i<=h1;i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
鄭楀諺
時間:
2018-5-5 15:31
#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;
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-5 15:32
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main()
{
srand(time(NULL));
int horse1,horse2,horse3,horse4=0;
int random;
while(true)
{
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;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"☆"<<endl;
cout<<"◆"<<endl;
while(horse1!=75 || horse2!=75 || horse3!=75 || horse4!=75)
{
for(int i=0;i<=horse1;i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=0;i<=horse2;i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=0;i<=horse3;i++)
{
cout<<" ";
}
cout<<"☆"<<endl;
for(int i=0;i<=horse4;i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
}
}
system("pause");
return 0;
}
複製代碼
作者:
顏詢
時間:
2018-5-12 12:05
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int a1=0,a2=0,a3=0,a4=0,random=0;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------[終點"<<endl;
cout<<"●"<<endl;
cout<<"▼"<<endl;
cout<<"■"<<endl;
cout<<"★"<<endl;
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<<"「好事成雙」賽馬場"<<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");
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2