標題:
賽馬程式 (二)
[打印本頁]
作者:
方浩葦
時間:
2024-7-27 11:15
標題:
賽馬程式 (二)
使畫面動起來
本帖隱藏的內容需要回復才可以瀏覽
作者:
林少謙
時間:
2024-7-27 15:03
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int x,y;
int a[]{0,0,0,0};
cout<<"空蕩蕩賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
re:
if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
{
system("cls");
cout<<"比賽開始"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=3; i++)
{
x=rand()%5+1;
a[i]+=x;
}
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(100);
goto re;
}
else
{
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李唯銘
時間:
2024-7-27 15:54
本帖最後由 李唯銘 於 2024-7-27 16:10 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
int a=0, b=0, c=0, d=0;
while(true){
system("cls");
cout<<"比賽中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;\
int r=rand()%4;
if(r==0){
a++;
}
else if(r==1){
b++;
}
else if(r==2){
c++;
}
else if(r==3){
d++;
}
for(int i=1; i<=a; i++){
cout<<" ";}
cout<<"◆"<<endl;
for(int j=1; j<=b; j++){
cout<<" ";}
cout<<"★"<<endl;
for(int k=1; k<=c; k++){
cout<<" ";}
cout<<"▲"<<endl;
for(int l=1; l<=d; l++){
cout<<" ";}
cout<<"●"<<endl;
_sleep(10);
if((a==73)||(b==73)||(c==73)||(d==73))
break;
}
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++){
cout<<" ";}
cout<<"◆"<<endl;
for(int j=1; j<=b; j++){
cout<<" ";}
cout<<"★"<<endl;
for(int k=1; k<=c; k++){
cout<<" ";}
cout<<"▲"<<endl;
for(int l=1; l<=d; l++){
cout<<" ";}
cout<<"●"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
劉奕劭
時間:
2024-7-27 15:55
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
cout<<"賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
int a[]{0,0,0,0};
int s;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
cout<<"比賽開始"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
re:
if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73){
system("cls");
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
s=rand()%4;
a[s]++;
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(10);
goto re;
}else{
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
for(int i=1; i<=a[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-7-27 16:00
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int x;
int a[]={0,0,0,0};
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"★"<<endl;
cout<<"■"<<endl;
cout<<"▼"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
re:
if(a[1]<73 && a[2]<73 && a[3]<73 && a[4]<73)
{
system("cls");
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=4; i++)
{
x=rand()%4;
a[i]+=x;
}
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"■"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"▼"<<endl;
for(int i=1; i<=a[4]; i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(25);
goto re;
}
else
{
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
}
for(int i=1; i<=a[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=a[2]; i++)
cout<<" ";
cout<<"■"<<endl;
for(int i=1; i<=a[3]; i++)
cout<<" ";
cout<<"▼"<<endl;
for(int i=1; i<=a[4]; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳妍蓁
時間:
2024-7-27 16:01
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
int x,y;
int n[]={0,0,0,0};
srand(time(NULL));
cout<<"「好事成雙」賽馬程式"<<endl;
cout<<"---------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
re:
if(n[0]<70&&n[1]<70&&n[2]<70&&n[3]<73){
system("cls");
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------|終點"<<endl;
int speed=2;
int i;
x=rand()%4;
n[x]++;
for(int i=1;i<=n[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1;i<=n[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1;i<=n[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1;i<=n[3];i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(speed);
goto re;
}
else{
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------|終點"<<endl;
for(int i=1;i<=n[0];i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1;i<=n[1];i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1;i<=n[2];i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1;i<=n[3];i++)
cout<<" ";
cout<<"●"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李偈睿
時間:
2024-8-10 14:35
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
re:
system("cls");
int s[]={0,0,0,0};
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"●"<<endl;
if(s[r]==73)
break;
_sleep(50);
}
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
李偈睿
時間:
2024-8-10 15:20
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
re:
system("cls");
int s[]={0,0,0,0};
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(true)
{
system("cls");
int r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"●"<<endl;
if(s[r]==73)
break;
_sleep(5);
}
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2