標題:
[隨堂測驗] 賽馬程式 (三)
[打印本頁]
作者:
李知易
時間:
2025-1-9 21:41
標題:
[隨堂測驗] 賽馬程式 (三)
1. 在比賽首頁顯示第幾局
2. 在比賽結束頁顯示哪一位選手勝出
本帖隱藏的內容需要回復才可以瀏覽
作者:
吳孟樵
時間:
2025-1-10 20:49
本帖最後由 吳孟樵 於 2025-2-1 11:53 編輯
#include<bits/stdc++.h>
using namespace std;
int main()
{
int r=0,n=1,speed=50;
re:
system("cls");
int s[4]= {0,0,0,0};
srand(time(NULL));
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------|終點"<<endl;
string p[4]= {"◆","★","▲","●"};
for(int i=0; i<=3; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=52)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(speed);
system("cls");
}
cout<<"比賽結束! 由"<<p[r]<<"先馳得點!"<<endl;
cout<<"------------------------------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
system("pause");
n++;
goto re;
return 0;
}
複製代碼
作者:
洪睿輿
時間:
2025-1-10 20:55
#include<bits/stdc++.h>
using namespace std;
int main()
{
int s[4]= {0,0,0,0};
string p[4]= {"1","2","3","4"};
srand(time(NULL));
cout<<"「好事成雙」賽馬場 第1局\n";
cout<<"------------------------|終點\n";
int r;
for(int i=0; i<4; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=18)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中\n";
cout<<"--------------------|\n";
for(int a=0; a<4; a++)
{
for(int j=0; j<s[a]; j++)
{
cout<<" ";
}
cout<<p[a]<<endl;
}
_sleep(50);
system("cls");
}
cout<<"比賽結束由,"<<p[r]<<"先馳得點\n";
cout<<"-------------------\n";
for(int a=0; a<4; a++)
{
for(int j=0; j<s[a]; j++)
{
cout<<" ";
}
cout<<p[a]<<endl;
}
return 0;
}
複製代碼
作者:
黃品錡
時間:
2025-1-10 21:57
本帖最後由 黃品錡 於 2025-1-16 16:58 編輯
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=0;
for(int a=0; a<5; a++)
{
n++;
system("cls");
int s[4]= {0,0,0,0};
int r;
int speed=1;
srand(time(NULL));
cout<<"「好事成雙」賽車場 第"<<n<<"局"<<endl;
cout<<"--------------------------------|終點"<<endl;
string p[4]= {"1","2","3","4"};
for(int i=0; i<=3; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=30)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(speed);
system("cls");
}
cout<<"比賽結束! 由"<<p[r]<<"號先馳得點!"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
陳婕愉
時間:
2025-1-11 10:47
#include<bits/stdc++.h>
using namespace std;
int n=0;
int main()
{
re:
n++;
system("cls");
int s[4]= {0,0,0,0};
string p[4]= {"馬1","馬2","馬3","馬4"};
int r;
srand(time(NULL));
cout<<"[好事成雙]賽馬場 第"<<n<<"局"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
for(int i=0; i<4; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=74)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-----------------------------------------------------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(50);
system("cls");
}
cout<<"比賽結束,由"<<p[r]<<"先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
鄭子宸
時間:
2025-1-11 13:16
#include<bits/stdc++.h>
using namespace std;
int n=0;
int main()
{
re:
n++;
system("cls");
int s[]= {0,0,0,0};
string p[]= {"◆","★","▲","●"};
int r;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<"第"<<n<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=71)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(25);
system("cls");
}
cout<<"比賽結束,由"<<p[r]<<"先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
system("pause");
system("cls");
goto re;
return 0;
}
複製代碼
作者:
楊昀瑾
時間:
2025-1-14 21:18
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=0;
for(int k=0; k<5; k++)
{
n++;
system("cls");
int s[4]= {0,0,0,0};
int r;
int speed=1;
srand(time(NULL));
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"--------------------------------|終點"<<endl;
string p[4]= {"◆","★","▲","●"};
for(int i=0; i<=3; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=30)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(speed);
system("cls");
}
cout<<"比賽結束! 由"<<p[r]<<"先馳得點!"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
江立辰
時間:
2025-1-15 21:54
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=0;
for(int a=0; a<5; a++)
{
n++;
system("cls");
int s[4]= {0,0,0,0};
int r;
int speed=1;
srand(time(NULL));
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"--------------------------------|終點"<<endl;
string p[4]= {"◆","★","▲","●"};
for(int i=0; i<=3; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=30)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(speed);
system("cls");
}
cout<<"比賽結束! 由"<<p[r]<<"先馳得點!"<<endl;
cout<<"----------------------------------|終點"<<endl;
for(int i=0; i<=3; i++)
{
for(int j=0; j<=s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
陳頎諠
時間:
2025-1-16 20:49
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int ov;
re:
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"8","7","6","5"};
int r=0;
cout<<"「好事成雙」賽馬場 第 "<<ov<<" 局"<<" 歡迎各貴公司投資"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<p[i]<<endl;
system("pause");
system("cls");
while(s[r]<=73)
{
r=rand()%4; //0~3
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
_sleep(50);
system("cls");
}
cout<<"比賽結束! 由 "<<p[r]<<" 先馳得點!"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
system("pause");
ov++;
goto re;
return 0;
}
複製代碼
作者:
彭郁程
時間:
2025-1-17 16:17
#include<bits/stdc++.h>
using namespace std;
int z=0;
int main()
{
re:
z++;
system("cls");
int s[]= {0,0,0,0};
string p[]= {"◆","★","▲","●"};
int r;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<"第"<<z<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=71)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(100);
system("cls");
}
cout<<"比賽結束,由"<<p[r]<<"先馳得點"<<endl;
cout<<"---------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
system("pause");
system("cls");
goto re;
return 0;
}
複製代碼
作者:
朱立人
時間:
2025-1-17 19:08
#include<bits/stdc++.h>
using namespace std;
int n=0;
int main()
{
re:
n++;
system("cls");
int s[]= {0,0,0,0};
string p[]= {"◆","★","▲","●"};
int r;
srand(time(NULL));
cout<<"「好事成雙」賽馬場"<<"第"<<n<<"局"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
cout<<p[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=71)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
{
cout<<" ";
}
cout<<p[i]<<endl;
}
_sleep(25);
system("cls");
}
cout<<"比賽結束,由"<<p[r]<<"先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
system("pause");
system("cls");
goto re;
return 0;
}
複製代碼
作者:
張詠博
時間:
2025-1-17 20:09
#include<bits\stdc++.h>
#include<cstdlib>
using namespace std;
int n=1;
int main()
{
re:
system("cls");
int r;
srand(time(NULL));
int s[]={0,0,0,0};
string a[]={"★","◆","●","▲"};
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"---------------| 終點"<<endl;
for(int i=0;i<4;i++)
{
cout<<a[i]<<endl;
}
system("pause");
system("cls");
while(s[r]<=15)
{
r=rand()%4;
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"---------------| 終點"<<endl;
for(int i=0;i<4;i++)
{
for(int j=0;j<s[i];j++)
cout<<" ";
cout<<a[i]<<endl;
}
_sleep(50);
system("cls");
}
system("cls");
cout<<"比賽結束"<<endl;
cout<<"---------------| 終點 由 "<<a[r]<<" 先馳得點!"<<endl;
for(int i=0;i<4;i++)
{
for(int j=0;j<s[i];j++)
cout<<" ";
cout<<a[i]<<endl;
}
system("pause");
n++;
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2