標題:
賽馬程式 "四匹馬PK"
[打印本頁]
作者:
周政輝
時間:
2017-10-17 18:23
標題:
賽馬程式 "四匹馬PK"
請將程式修改成四匹馬PK
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0, random=0;
srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽馬場"<<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");
}
}
system("pause");
return 0;
}
複製代碼
作者:
顏羽彤
時間:
2017-10-17 18:24
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0,random=0;
srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽馬場"<<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");
}
}
system("pause");
return 0;
}
複製代碼
作者:
巫沛庭
時間:
2017-10-17 18:25
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
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");
}
}
system("pause");
return 0;
}
作者:
巫晉宇
時間:
2017-10-17 18:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int gay1=0, gay2=0, gay3=0, gay4=0, rad=0;
system("cls");
cout<<"尬賽馬場"<<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; //產生0~3之隨機亂數
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");
}
system("pause");
return 0;
}
作者:
張閎鈞
時間:
2017-10-17 18:29
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
while(true)
{
int cat1=0, cat2=0, cat3=0, cat4=0, random=0;
system("cls");
cout<<"「好事成雙」賽馬場"<<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");
}
}
system("pause");
return 0;
}
複製代碼
作者:
張凱婷
時間:
2017-10-17 18:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
while(true)
{
int girl1=0, girl2=0, girl3=0, girl4=0, LOL=0;
system("cls");
cout<<"賽跑場"<<endl;
cout<<"----------------------------------------------------------------|你終於到了"<<endl;
cout<<"♀瓦搭溪"<<endl;
cout<<"♀洪珝喬"<<endl;
cout<<"♀黃脩涵"<<endl;
cout<<"♀陳采蘊"<<endl;
system("pause");
system("cls");
while(girl1!=61 && girl2!=61 && girl3!=61 && girl4!=61)
{
LOL=rand()%4;
if(LOL==0)
girl1++;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------------------------------------|你終於到了"<<endl;
for(int i=1; i<=girl1; i++)
cout<<" ";
cout<<"♀瓦搭溪"<<endl;
LOL=rand()%4;
if(LOL==1)
girl2++;
for(int i=1; i<=girl2; i++)
cout<<" ";
cout<<"♀洪珝喬"<<endl;
LOL=rand()%4;
if(LOL==2)
girl3++;
for(int i=1; i<=girl3; i++)
cout<<" ";
cout<<"♀黃脩涵"<<endl;
LOL=rand()%4;
if(LOL==0)
girl4++;
for(int i=1; i<=girl4; i++)
cout<<" ";
cout<<"♀陳采蘊"<<endl;
system("cls");
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2