標題:
賽馬程式 (二)
[打印本頁]
作者:
may
時間:
2023-3-6 18:16
標題:
賽馬程式 (二)
使畫面動起來
本帖隱藏的內容需要回復才可以瀏覽
作者:
羅紹齊
時間:
2023-3-11 15:26
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
srand(time(NULL));
int r=0;
int s[]={0,0,0,0};
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(s[r]<70){
r=rand()%4;
s[r]++;
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;
_sleep (10);
}
system("pause");
return 0;
}
複製代碼
作者:
翁川祐
時間:
2023-3-11 15:28
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
system("cls");
srand(time(NULL));
int x[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int y=0;
cout<<"「好事不成雙 見好就收」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<p[i]<<endl;
system("pause");
system("cls");
while(x[y]<=73)
{
y=rand()%4;
x[y]++;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<x[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
_sleep(25);
system("cls");
}
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<x[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳泓亦
時間:
2023-3-11 15:32
#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;
}
複製代碼
作者:
徐啟祐
時間:
2023-3-11 15:33
本帖最後由 徐啟祐 於 2023-3-14 14:53 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
re:
system("cls");
srand(time(NULL));
string p[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r=0;
cout<<"「好事成霜」賽馬場"<<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(20);
system("cls");
}
cout<<"比賽結束"<<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");
goto re;
return 0;
}
複製代碼
作者:
陳宥霖
時間:
2023-3-12 21:51
本帖最後由 陳宥霖 於 2023-3-12 22:03 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
system("cls");
srand(time(NULL));
int s[]={0,0,0,0};
string p[]={"◆","★","▲","●"};
int r=0;
cout<<"#好事成雙 見好就收# 賽馬場"<<endl;
cout<<"-----------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<p[i]<<endl;
system("pause");
system("cls");
while(s[r]<=70)
{
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<<"比賽結束"<<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");
return 0;
}
複製代碼
作者:
楊芊琦
時間:
2023-3-17 21:54
#include<iostream>
#include<cstdlib>
#include<ctime>
#include <chrono>
#include <thread>
using namespace std;
int main()
{
srand(time(NULL));
int steps[] = {0,0,0,0};
string shape[] = { "◆","★","▲","●" };
cout << "超坑錢賽馬場" << endl;
cout << "-------------------------------------------------------------------------|終點";
this_thread::sleep_for(std::chrono::milliseconds(2000));
int w = 0;int plus;
while (w <= 71)
{
cout << "比賽進行中" << endl;
cout << "-------------------------------------------------------------------------|終點" << endl;
steps[rand() % 4] += 1;
w = steps[rand() % 4];
for (int s = 0;s <= steps[0];s++)
cout << " ";
cout << shape[0] << endl;
for (int s = 0;s <= steps[1];s++)
cout << " ";
cout << shape[1] << endl;;
for (int s = 0;s <= steps[2];s++)
cout << " ";
cout << shape[2] << endl;
for (int s = 0;s <= steps[3];s++)
cout << " ";
cout << shape[3] << endl;
this_thread::sleep_for(std::chrono::milliseconds(1));
if (w ==71)
{
system("pause");
return 0;
}
system("cls");
}
}
複製代碼
作者:
陳牧謙
時間:
2023-3-18 09:04
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
system("cls");
srand(time(NULL));
int x[]={0,0,0,0};
string p[]={"赤兔","的盧","照獅","絕影"};
int y=0;
re:
cout<<"「壞事成三」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<p[i]<<endl;
system("pause");
system("cls");
while(x[y]<=73)
{
y=rand()%4;
x[y]++;
cout<<"比賽進行中"<<endl;
cout<<"----------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<x[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
_sleep(25);
system("cls");
}
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<x[i]; j++)
cout<<" ";
cout<<p[i]<<endl;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
宜儒
時間:
2023-3-18 12:42
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
srand(time(NULL));
re:
system("cls");
int r=0; //0~3
int s[]={0,0,0,0}; //每匹馬左側的空白數
cout<<"好事成雙賽馬場"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
while(s[r]<70){ //只要有任何一匹馬到達終點,迴圈就會停下來
r=rand()%4; //r=0~3
s[r]++;
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;
_sleep(10);
}
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;
}
複製代碼
作者:
羅暐傑
時間:
2023-3-18 14:18
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
re:
system("cls");
srand(time(NULL));
string p[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r=0;
cout<<"歡迎光臨騙你錢賽馬場"<<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;
}
system("cls");
}
cout<<"比賽結束"<<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");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2