標題:
賽馬程式 (二)
[打印本頁]
作者:
tonyh
時間:
2016-10-15 10:34
標題:
賽馬程式 (二)
本帖最後由 tonyh 於 2016-10-15 11:54 編輯
使畫面動起來
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
string n[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r;
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<n[i]<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4; //0~3
s[r]++;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
_sleep(10);
system("cls");
if(s[r]==76)
break;
}
cout<<"比賽結果"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
system("pause");
goto re;
return 0;
}
複製代碼
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=0,b=0,c=0,d=0;
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
while(a!=76 && b!=76 && c!=76 && d!=76)
{
int r=rand()%4; //0~3
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<d; i++)
cout<<" ";
cout<<"●"<<endl;
_sleep(10);
system("cls");
}
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
黃茂勛
時間:
2016-10-15 11:20
本帖最後由 黃茂勛 於 2016-10-15 11:42 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
string n[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
cout<<"「場賽馬賽場馬」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<n[i]<<endl;
system("pause");
while(true)
{
int 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<<n[i]<<endl;
}
_sleep(10);
system("cls");
if(s[r]==76)
break;
}
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
system("pause");
goto re;
return 0;
}
複製代碼
作者:
陸長辰
時間:
2016-10-15 11:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
string n[]={"◆","★","▲","●"};
int s[]={0,0,0,0};
int r;
cout<<"「87878787878787878787878787」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
cout<<n[i]<<endl;
system("pause");
while(true)
{
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4;
s[r]++;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
_sleep(10);
system("cls");
if(s[r]==76)
break;
}
cout<<"比賽結果"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<4; i++)
{
for(int j=0; j<s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
system("pause");
goto re;
return 0;
}
複製代碼
作者:
林侑成
時間:
2016-10-15 11:41
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
srand(time(NULL));
re:
system("cls");
string n[]={"◆","★","▲","●","幹"};
int s[]={0,0,0,0,0};
int r;
cout<<"「nfjklheltgj;akerj」賽馬場"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=4; i++)
cout<<n[i]<<endl;
system("pause");
system("cls");
race:
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
r=rand()%5;
s[r]++;
for(int i=0; i<=4; i++){
for(int j=0; j<=s[i]; j++)
cout<<" ";
cout<<n[i]<<endl;
}
if(s[r]==75)
goto finish;
_sleep(10);
system("cls");
goto race;
finish:
system("pause");
goto re;
return 0;
}
複製代碼
作者:
陳泓瑜
時間:
2016-10-29 09:55
本帖最後由 陳泓瑜 於 2016-10-29 11:11 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
re:
system("cls");
int a=0,b=0,c=0,d=0;
cout<<"狗屁'賽'馬場"<<endl;
cout<<"-------------------------------------------------------------------------|FINISH";
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
cout<<"4"<<endl;
system("pause");
system("cls");
while(a!=74 && b!=74 && c!=74 && d!=74)
{
int r=rand()%4; //0~3
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"開始放屁中"<<endl;
cout<<"-------------------------------------------------------------------------|FINISH";
for(int i=0; i<a; i++)
cout<<"_";
cout<<"1"<<endl;
for(int i=0; i<b; i++)
cout<<"_";
cout<<"2"<<endl;
for(int i=0; i<c; i++)
cout<<"_";
cout<<"3"<<endl;
for(int i=0; i<d; i++)
cout<<"_";
cout<<"4"<<endl;
system("cls");
}
cout<<"GAME OVER!!"<<endl;
cout<<"-------------------------------------------------------------------------|FINISH";
for(int i=0; i<a; i++)
cout<<"_";
cout<<"1"<<endl;
for(int i=0; i<b; i++)
cout<<"_";
cout<<"2"<<endl;
for(int i=0; i<c; i++)
cout<<"_";
cout<<"3"<<endl;
for(int i=0; i<d; i++)
cout<<"_";
cout<<"4"<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2