標題:
賽馬程式 (二)
[打印本頁]
作者:
王瑞喻
時間:
2019-12-5 01:15
標題:
賽馬程式 (二)
本帖最後由 王瑞喻 於 2019-12-28 14:30 編輯
讓馬匹隨機往終點移動
[attach]8047[/attach]
本帖隱藏的內容需要回復才可以瀏覽
作者:
洪藜芸
時間:
2019-12-7 11:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand(time(NULL));
cout<<"賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
int r=rand()%4;
h[r]++;
for(int i=1;i<=h[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<=h[2];i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1;i<=h[3];i++)
{
cout<<" ";
}
cout<<"●"<<endl;
if(h[r]==72)
{
break;
}
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
郭哲維
時間:
2019-12-7 11:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand(time(NULL));
cout<<"賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
int r=rand()%4;
h[r]++;
for(int i=1;i<=h[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<=h[2];i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1;i<=h[3];i++)
{
cout<<" ";
}
cout<<"●"<<endl;
if(h[r]==72)
{
break;
}
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
洪子涵
時間:
2019-12-7 12:03
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"[好事成雙]賽馬場\n----------------------------------------------------------|終點"<<endl;
cout<<"▲"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
int h[4]={0,0,0,0};
while(true)
{
cout<<"比賽進行中\n------------------------------------------------------------|終點"<<endl;
int r=rand()%4;
h[r]++;
for(int i=0;i<=h[0];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0;i<=h[1];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0;i<=h[2];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0;i<=h[3];i++)
cout<<" ";
cout<<"●"<<endl;
if(h[r]==60)
break;
_sleep(30);
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
黃傳耀
時間:
2019-12-7 12:08
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int r ;
srand(time(NULL));
int h[4] = {0,0,0,0};
cout<<"賽馬場"<<endl<<"----------------------------------------終點"<<endl;
cout<<"◆"<<endl<<"★"<<endl<<"▲"<<endl<<"●"<<endl;
system("pause");
system("cls");
while(true)
{
cout<<"比賽中"<<endl<<"----------------------------------------終點"<<endl;
r = rand()%4;
h[r]++;
for(int i=1;i<=h[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
{
cout<<" ";
}
cout<<"★"<<endl;for(int i=1;i<=h[2];i++)
{
cout<<" ";
}
cout<<"▲"<<endl;for(int i=1;i<=h[3];i++)
{
cout<<" ";
}
cout<<"●"<<endl;
if(h[r]>=40)
break;
_sleep(10);
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
蔡少宇
時間:
2019-12-7 12:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int r=rand()%4;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls")
system("pause");
return 0;
}
複製代碼
作者:
林孟蓁
時間:
2019-12-8 16:34
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand (time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-----------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(true)
{
int r=rand()%4;
h[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-----------------------------------------------------------------------|終點"<<endl;
for(int k=1; k<=h[0]; k++)
cout<<" ";
cout<<"◆"<<endl;
for(int k=1; k<=h[1]; k++)
cout<<" ";
cout<<"★"<<endl;
for(int k=1; k<=h[2]; k++)
cout<<" ";
cout<<"▲"<<endl;
for(int k=1; k<=h[3]; k++)
cout<<" ";
cout<<"●"<<endl;
if(h[r]==71)
break;
_sleep(10);
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
王瑞喻
時間:
2019-12-9 15:40
回復
7#
林孟蓁
作者:
鄭羽捷
時間:
2019-12-13 20:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand(time(NULL));
cout<<"賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
int r=rand()%4;
h[r]++;
for(int i=1;i<=h[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<=h[2];i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1;i<=h[3];i++)
{
cout<<" ";
}
cout<<"●"<<endl;
if(h[r]==72)
{
break;
}
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
王翎璇
時間:
2019-12-14 10:41
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand (time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-----------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(true)
{
int r=rand()%4;
h[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-----------------------------------------------------------------------|終點"<<endl;
for(int k=1; k<=h[0]; k++)
cout<<" ";
cout<<"◆"<<endl;
for(int k=1; k<=h[1]; k++)
cout<<" ";
cout<<"★"<<endl;
for(int k=1; k<=h[2]; k++)
cout<<" ";
cout<<"▲"<<endl;
for(int k=1; k<=h[3]; k++)
cout<<" ";
cout<<"●"<<endl;
if(h[r]==71)
break;
_sleep(10);
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
曾宥程
時間:
2019-12-14 16:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand(time(NULL));
cout<<"賽馬場"<<endl;
cout<<"------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl<<"★"<<endl<<"▲"<<endl<<"●"<<endl; //72
system("pause");
system("cls");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------|終點"<<endl;
int r=rand()%4;
h[r]++;
for(int i=1;i<=h[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<=h[2];i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1;i<=h[3];i++)
{
cout<<" ";
}
cout<<"●"<<endl;
if(h[r]==72)
break;
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
陳宇柏
時間:
2019-12-17 20:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand(time(NULL));
cout<<"賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
int r=rand()%4;
h[r]++;
for(int i=1;i<=h[0];i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1;i<=h[2];i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1;i<=h[3];i++)
{
cout<<" ";
}
cout<<"●"<<endl;
if(h[r]==72)
{
break;
}
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
王建葦
時間:
2019-12-28 14:31
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int h[4]={0,0,0,0};
srand(time(NULL));
cout<<"[好事雙城]賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中......"<<endl;
int r=rand()%4;
h[r]++;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1;i<=h[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1;i<=h[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1;i<=h[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1;i<=h[3];i++)
cout<<" ";
cout<<"●"<<endl;
if(h[r]==72)
{
break;
}
_sleep(20);
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
駱顗安
時間:
2020-8-27 20:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int d[]={0,0,0,0},speed=30;
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-----------------------------------------------------------------| 終點"<<endl;
cout<<"●"<<endl;
cout<<"▲"<<endl;
cout<<"★"<<endl;
cout<<"◆"<<endl;
system("pause");
while(true)
{
system("cls");
cout<<"比賽進行中"<<endl;
cout<<"-----------------------------------------------------------------| 終點"<<endl;
int g=rand()%4;
d[g]++;
for(int a=0;a<=d[0];a++)
cout<<" ";
cout<<"●"<<endl;
for(int b=0;b<=d[1];b++)
cout<<" ";
cout<<"▲"<<endl;
for(int c=0;c<=d[2];c++)
cout<<" ";
cout<<"★"<<endl;
for(int e=0;e<=d[3];e++)
cout<<" ";
cout<<"◆"<<endl;
if(d[0]>=64||d[1]>=64||d[2]>=64||d[3]>=64)
break;
_sleep(speed);
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2