標題:
[作業] 賽馬程式 (三)
[打印本頁]
作者:
tonyh
時間:
2014-4-12 17:54
標題:
[作業] 賽馬程式 (三)
本帖最後由 tonyh 於 2014-4-19 16:28 編輯
1. 在比賽首頁顯示第幾局
2. 在比賽結束頁顯示哪一位選手勝出
[attach]875[/attach]
[attach]876[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1;
re1:
int a=0, b=0, c=0, d=0, r;
system("cls");
cout<<"「好事成雙」賽馬場 第 "<<n<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
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=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2014-4-12 18:09
本帖最後由 張峻瑋 於 2014-4-19 16:31 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int e=1;
re1:
int a=0,b=0,c=0,d=0,r;
system("cls");
cout<<"$ 888賽馬場 第"<<e<<"局 $"<<endl;
cout<<"--------------------------------------------------------------------------│"<<endl;
cout<<"◢1◤"<<endl;
cout<<"◢2◤"<<endl;
cout<<"◢3◤"<<endl;
cout<<"◢4◤"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------│終點"<<endl;
for(int i=1;i<=a;i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1;i<=b;i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1;i<=c;i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1;i<=d;i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("cls");
}
cout<<"比賽結束!由 ";
if(a==75)
cout<<"◢1◤";
if(b==75)
cout<<"◢2◤";
if(c==75)
cout<<"◢3◤";
if(d==75)
cout<<"◢4◤";
cout<<" 先馳得點"<<endl;
cout<<"--------------------------------------------------------------------------│終點"<<endl;
for(int i=1;i<=a;i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1;i<=b;i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1;i<=c;i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1;i<=d;i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("pause");
e++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2014-4-12 18:10
本帖最後由 周雍程 於 2014-4-25 20:26 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int e=1;
re1:
int a=0, b=0, c=0, d=0, r;
system("cls");
cout<<"$賺大錢賽馬場$ 第"<<e<<"局"<<endl;
cout<<"------------------------------------------------------------------------│終點"<<endl;
cout<<"◢ 1▋"<<endl;
cout<<"◢ 2▋"<<endl;
cout<<"◢ 3▋"<<endl;
cout<<"◢ 4▋"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=73 && b!=73 && c!=73 && d!=73)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------│終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢ 1▋"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢ 2▋"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢ 3▋"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢ 4▋"<<endl;
system("cls");
}
cout<<"比賽結束"<<endl;
if(a==73)
cout<<"由"<<"◢ 1▋"<<"先馳得點"<<endl;
if(b==73)
cout<<"由"<<"◢ 2▋"<<"先馳得點"<<endl;
if(c==73)
cout<<"由"<<"◢ 3▋"<<"先馳得點"<<endl;
if(d==73)
cout<<"由"<<"◢ 4▋"<<"先馳得點"<<endl;
cout<<"------------------------------------------------------------------------│終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢ 1▋"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢ 2▋"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢ 3▋"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢ 4▋"<<endl;
system("pause");
e++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2014-4-12 18:10
本帖最後由 張彥承 於 2014-4-19 16:32 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
int n=0;
re1:
int a=0,b=0,c=0,d=0,r;
system("cls");
cout<<"天觀馬場 第"<<<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
cout<<"○"<<endl;
cout<<"※"<<endl;
cout<<"▽"<<endl;
cout<<"◆"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
e++;
cout<<"--------------------------------------------------------------------|終點"<<endl;
for(int i=1;i<=a;i++)
cout<<" ";
cout<<"○"<<endl;
for(int i=1;i<=b;i++)
cout<<" ";
cout<<"※"<<endl;
for(int i=1;i<=c;i++)
cout<<" ";
cout<<"▽"<<endl;
for(int i=1;i<=d;i++)
cout<<" ";
cout<<"◆"<<endl;
system("cls");
}
cout<<"比賽結束"<<endl;
if(75==a)
cout<<"由"<<" ○"<<"先馳得點"<<endl;
if(75==b)
cout<<"由"<<"※ "<<"先馳得點"<<endl;
if(75==c)
cout<<"由"<<" ▽"<<"先馳得點"<<endl;
if(75==d)
cout<<"由"<<"◆ "<<"先馳得點"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
for(int i=1;i<=a;i++)
cout<<" ";
cout<<"○"<<endl;
for(int i=1;i<=b;i++)
cout<<" ";
cout<<"※"<<endl;
for(int i=1;i<=c;i++)
cout<<" ";
cout<<"▽"<<endl;
for(int i=1;i<=d;i++)
cout<<" ";
cout<<"◆"<<endl;
system("pause");
n++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2014-4-18 20:49
本帖最後由 施伯叡 於 2014-4-19 16:29 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1;
re:
int a=0, b=0, c=0, d=0, r ;
system("cls");
cout<<"「穩賺不賠」賽馬場 <第"<<n<<"場>"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"★1☆"<<endl;
cout<<"☆2★"<<endl;
cout<<"★3☆"<<endl;
cout<<"☆4★"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && b!=70)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中..."<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"★1☆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"☆2★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"★3☆"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆4★"<<endl;
system("cls");
}
if(a>b && a>c && a>d)
cout<<"比賽結束,由1號選手先馳得點"<<endl;
if(b>a && b>c && b>d)
cout<<"比賽結束,由2號選手先馳得點"<<endl;
if(c>a && c>b && c>d)
cout<<"比賽結束,由3號選手先馳得點"<<endl;
if(d>a && d>b && d>c)
cout<<"比賽結束,由4號選手先馳得點"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"★1☆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"☆2★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"★3☆"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆4★"<<endl;
system("pause");
n++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2014-4-18 22:34
本帖最後由 劉得旗 於 2014-4-19 16:35 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int e=1;
re1:
int a=0, b=0, c=0, d=0, r;
system("cls");
cout<<"gg賽馬場 第 "<<e<<" 局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("cls");
}
cout<<"比賽結束! 由 ";
if(a==75)
cout<<"◆";
else if(b==75)
cout<<"★";
else if(c==75)
cout<<"▲";
else
cout<<"●";
cout<<" 獲勝!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
e++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2014-4-19 12:17
本帖最後由 張郁庭 於 2014-4-19 16:34 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int t=1;
re1:
int a=0, b=0, c=0, d=0, r;
system("cls");
cout<<"﹩財源滾滾賽馬場 ﹩";
cout<<" 第"<<t<<"局"<<endl;
cout<<"=========================================================================| 終點"<<endl;
cout<<"◢1◤"<<endl;
cout<<"◢2◤"<<endl;
cout<<"◢3◤"<<endl;
cout<<"◢4◤"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"=========================================================================| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("cls");
}
cout<<"比賽結束";
if(a==75)
cout<<" 由◢1◤獲得勝利"<<endl;
else if(b==75)
cout<<" 由◢2◤獲得勝利"<<endl;
else if(c==75)
cout<<" 由◢3◤獲得勝利"<<endl;
else
cout<<" 由◢4◤獲得勝利"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"◢1◤"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"◢2◤"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◢3◤"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"◢4◤"<<endl;
system("pause");
t++;
goto re1;
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2014-4-19 16:39
本帖最後由 張郁偵 於 2014-4-19 16:50 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1;
re1:
int a=0,b=0,c=0,d=0,r;
system("cls");
cout<<">酷炫賽馬場< 第"<<n++<<"局"<<endl;
cout<<"=========================================================================|終點"<<endl;
cout<<"∞"<<endl;
cout<<"△"<<endl;
cout<<"◇"<<endl;
cout<<"☆"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=75 && b!=75 && c!=75 && d!=75)
{
r=rand()%4;
if(r==0)
a++;
else if(r==1)
b++;
else if(r==2)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"=========================================================================|終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"∞"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"△"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◇"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆"<<endl;
system("cls");
}
cout<<"比賽結束 由";
if(a==75)
cout<<"∞";
else if(b==75)
cout<<"△";
else if(c==75)
cout<<"◇";
else
cout<<"●";
cout<<" 先馳得點!"<<endl;
cout<<"=========================================================================|終點"<<endl;
for(int i=1; i<=a; i++)
cout<<" ";
cout<<"∞"<<endl;
for(int i=1; i<=b; i++)
cout<<" ";
cout<<"△"<<endl;
for(int i=1; i<=c; i++)
cout<<" ";
cout<<"◇"<<endl;
for(int i=1; i<=d; i++)
cout<<" ";
cout<<"☆"<<endl;
system("pause");
goto re1;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2