標題:
賽馬程式 (二)
[打印本頁]
作者:
周政輝
時間:
2017-10-17 18:53
標題:
賽馬程式 (二)
1. 在比賽首頁顯示第幾局
2. 在比賽結束頁顯示哪一位選手勝出
[attach]2844[/attach]
[attach]2845[/attach]
#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));
system("cls");
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; //產生0~3之隨機亂數
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");
cout<<"比賽結束! 由 ";
if(horse1 == 75) {
cout<< "◆" << "先馳得點" << endl;
}
else if (horse2 == 75) {
cout<< "★" << "先馳得點" << endl;
}
else if (horse3 == 75) {
cout<< "▲" << "先馳得點" << endl;
}
else if (horse4 == 75) {
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("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
巫沛庭
時間:
2017-10-17 19:00
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=0;
while(true)
{
int horse1=0,horse2=0,horse3=0,horse4=0,random=0;
system("cls");
srand(time(NULL));
cout<<"人山人海人見人愛 賽馬場"<<endl;
cout<<"---------------------------------------------|終點"<<endl;
cout<<"Q"<<endl;
cout<<"∮"<<endl;
cout<<"㊣"<<endl;
cout<<"♂"<<endl;
system("pause");
system("cls");
while(horse1!=45&&horse2!=45&&horse3!=45&&horse4!=45)
{
random=rand()%4;
if(random==0)
horse1++;
if(random==1)
horse2++;
if(random==2)
horse3++;
if(random==3)
horse4++;
cout<<"比賽進行中"<<endl;
cout<<"---------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++)
cout<<" ";
cout<<"Q"<<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++;
cout<<"比賽結束!由";
if(horse1==45)
cout<<"Q獲勝~~"<<endl;
else if(horse2==45)
cout<<"∮獲勝~~"<<endl;
else if(horse3==45)
cout<<"㊣獲勝~~"<<endl;
else if(horse1=4==45)
cout<<"♂獲勝~~"<<endl;
cout<<"---------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++)
cout<<" ";
cout<<"Q"<<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("pause");
}
system("pause");
return 0;
}
作者:
顏羽彤
時間:
2017-10-17 19:01
#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));
system("cls");
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; //產生0~3之隨機亂數
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++;
cout<<"比賽結束 由";
if(horse1==75)
{
cout<<"◆";
}
if(horse2==75)
{
cout<<"★";
}
if(horse3==75)
{
cout<<"▲";
}
if(horse4==75)
{
cout<<"●";
}
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("pause");
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
張閎鈞
時間:
2017-10-17 19:01
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int time=1;
while(true)
{
int cat1=0, cat2=0, cat3=0, cat4=0, random=0;
system("cls");
cout<<"「好事成雙」賽馬場"<< time<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(cat1!=75 && cat2!=75 && cat3!=75 && cat4!=75)
{
random=rand()%4; //產生0~3之隨機亂數
if(random==0)
cat1++;
else if(random==1)
cat2++;
else if(random==2)
cat3++;
else if(random==3)
cat4++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=cat1; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=cat2; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=cat3; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=cat4; i++)
cout<<" ";
cout<<"□"<<endl;
system("cls");
}
time++ ;
if(cat1==75)
{
cout<<"◆成為小小的冠軍"<<endl;
}
else if(cat2==75)
{
cout<<"★成為小小的冠軍"<<endl;
}
else if(cat3==75)
{
cout<<"▲成為小小的冠軍"<<endl;
}
else
{
cout<<"□成為小小的冠軍"<<endl;
}
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=cat1; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=cat2; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=cat3; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=cat4; i++)
cout<<" ";
cout<<"□"<<endl;
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
張凱婷
時間:
2017-10-17 19:14
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int girl1=0, girl2=0, girl3=0, girl4=0, random=0;
srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽跑場 " << "第 " <<times << "場 "<<endl;
cout<<"-------------------------------------------------------| 終點"<<endl;
cout<<"♀瓦搭溪"<<endl;
cout<<"♀洪珝喬"<<endl;
cout<<"♀黃脩涵"<<endl;
cout<<"♀陳采蘊"<<endl;
system("pause");
system("cls");
while(girl1!=60 && girl2!= 60 && girl3!=60 && girl4!=60 )
{
random=rand()%4;
if(random==0) {
girl1++;
}
else if(random==1) {
girl2++;
}
else if(random==2) {
girl3++;
}
else if(random==3) {
girl4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=girl1; i++) {
cout<<" ";
}
cout<<"♀瓦搭溪"<<endl;
for(int i=1; i<=girl2; i++) {
cout<<" ";
}
cout<<"♀洪珝喬"<<endl;
for(int i=1; i<=girl3; i++) {
cout<<" ";
}
cout<<"♀黃脩涵"<<endl;
for(int i=1; i<=girl4; i++) {
cout<<" ";
}
cout<<"♀陳采蘊"<<endl;
system("cls");
}
times++;
system("cls");
cout<<"比賽結束! 由 ";
if(girl1 == 75) {
cout<< "♀瓦搭溪" << "先馳得點" << endl;
}
else if (girl2 == 75) {
cout<< "♀洪珝喬" << "先馳得點" << endl;
}
else if (girl3 == 75) {
cout<< "♀黃脩涵" << "先馳得點" << endl;
}
else if (girl4 == 75) {
cout<< "♀陳采蘊" << "先馳得點" << endl;
}
cout<<"------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=girl1; i++) {
cout<<" ";
}
cout<<"♀瓦搭溪"<<endl;
for(int i=1; i<=girl2; i++) {
cout<<" ";
}
cout<<"♀洪珝喬"<<endl;
for(int i=1; i<=girl3; i++) {
cout<<" ";
}
cout<<"♀黃脩涵"<<endl;
for(int i=1; i<=girl4; i++) {
cout<<" ";
}
cout<<"♀陳采蘊"<<endl;
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
顏羽彤
時間:
2017-10-17 19:32
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
void Result(int horse1,int horse2,int horse3,int horse4)
{
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;
}
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0,random=0;
srand(time(NULL));
system("cls");
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; //產生0~3之隨機亂數
if(random==0)
{
horse1++;
}
else if(random==1)
{
horse2++;
}
else if(random==2)
{
horse3++;
}
else if(random==3)
{
horse4++;
}
cout<<"比賽進行中"<<endl;
Result(horse1,horse2,horse3,horse4);
system("cls");
}
times++;
cout<<"比賽結束 由";
if(horse1==75)
{
cout<<"◆";
}
if(horse2==75)
{
cout<<"★";
}
if(horse3==75)
{
cout<<"▲";
}
if(horse4==75)
{
cout<<"●";
}
cout<<"先馳得點!"<<endl;
Result(horse1,horse2,horse3,horse4);
system("pause");
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
巫晉宇
時間:
2017-10-24 18:52
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int tim=1;
while(true)
{
int gay1=0, gay2=0, gay3=0, gay4=0, rad=0;
srand(time(NULL));
system("cls");
cout<<"尬賽馬場 "<< "第" <<tim << "局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(gay1!=75 && gay2!=75 && gay3!=75 && gay4!=75)
{
rad=rand()%4;
if(rad==0)
{ gay1++;}
else if(rad==1)
{ gay2++;}
else if(rad==2)
{ gay3++;}
else if(rad==3)
{ gay4++; }
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=gay1; i++)
{ cout<<" ";}
cout<<"◆"<<endl;
for(int i=1; i<=gay2; i++)
{ cout<<" ";}
cout<<"★"<<endl;
for(int i=1; i<=gay3; i++)
{ cout<<" ";}
cout<<"▲"<<endl;
for(int i=1; i<=gay4; i++)
{ cout<<" ";}
cout<<"●"<<endl;
system("cls");
}
tim++;
system("cls");
cout<<"比賽結束! 由 ";
if(gay1 == 75) {
cout<< "◆" << "先到終點" << endl;
}
else if (gay2 == 75) {
cout<< "★" << "先到終點" << endl;
}
else if (gay3 == 75) {
cout<< "▲" << "先到終點" << endl;
}
else if (gay4 == 75) {
cout<< "●" << "先到終點" << endl;
}
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=gay1; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=gay2; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=gay3; i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=gay4; i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("pause");
}
system("pause");
return 0;
}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2