標題:
[作業] 賽馬程式 (三)
[打印本頁]
作者:
tonyh
時間:
2015-7-18 10:52
標題:
[作業] 賽馬程式 (三)
本帖最後由 tonyh 於 2015-8-15 11:25 編輯
1. 在比賽首頁顯示第幾局
2. 在比賽結束頁顯示哪一位選手勝出
[attach]1306[/attach]
[attach]1307[/attach]
本帖隱藏的內容需要回復才可以瀏覽
作者:
謝瀞儀
時間:
2015-7-18 11:16
自己做的不完整版
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
first:
int money,join,gambling;
cout<<"Do you want to join the casino?(1)Yes (2)No";
cin>>join;
if(join==1)
goto re;
else if(join==2)
goto playout;
else
{
cout<<"There has no chose of"<<"''"<<join<<"''.";
goto first;
}
re:
system("cls");
int x=0,b=0,g=0,u=0,l=0,p=0,r;
cout<<"How much money would you pay?";
cin>>money;
if(money<0)
{
cout<<"You did not pay the correct number.";
goto re;
}
srand(time(NULL));
cout<<"「Greece letter Casino」Race court"<<endl;
cout<<"---------------------------------------------------------|FIN"<<endl;
cout<<"χ"<<endl;
cout<<"β"<<endl;
cout<<"γ"<<endl;
cout<<"μ"<<endl;
cout<<"λ"<<endl;
cout<<"π"<<endl;
choose:
cout<<endl<<"Who would you gambling?(1)χ (2)β (3)γ (4)μ (5)λ (6)π";
cin>>gambling;
if(gambling<1 or gambling>6)
{
cout<<"There is no chose of"<<"''"<<gambling<<"''.";
goto choose;
}
else
goto down;
down:
system("pause");
if(gambling==1)
gambling==x;
else if(gambling==2)
gambling==b;
else if(gambling==3)
gambling==g;
else if(gambling==4)
gambling==u;
else if(gambling==5)
gambling==l;
else
gambling==p;
while(x<=55 and b<=55 and g<=55 and u<=55 and l<=55 and p<=55)
{
r=rand()%6+1;
if(r==1)
x++;
else if(r==2)
b++;
else if(r==3)
g++;
else if(r==4)
u++;
else if(r==5)
l++;
else
p++;
cout<<"「Greece letter Casino」Race court GAME ON"<<endl;
cout<<"---------------------------------------------------------|FIN"<<endl;
for(int i=0 ;i<=x ;i++)
cout<<" ";
cout<<"χ"<<endl;
for(int i=0 ;i<=b ;i++)
cout<<" ";
cout<<"β"<<endl;
for(int i=0 ;i<=g; i++)
cout<<" ";
cout<<"γ"<<endl;
for(int i=0 ;i<=u; i++)
cout<<" ";
cout<<"μ"<<endl;
for(int i=0; i<=l ;i++)
cout<<" ";
cout<<"λ"<<endl;
for(int i=0; i<=p ;i++)
cout<<" ";
cout<<"π"<<endl;
system("cls");
}
cout<<"「Greece letter Casino」Race court GAME OVER"<<endl;
cout<<"---------------------------------------------------------|FIN"<<endl;
for(int i=0 ;i<=x ;i++)
cout<<" ";
cout<<"χ"<<endl;
for(int i=0 ;i<=b ;i++)
cout<<" ";
cout<<"β"<<endl;
for(int i=0 ;i<=g; i++)
cout<<" ";
cout<<"γ"<<endl;
for(int i=0 ;i<=u; i++)
cout<<" ";
cout<<"μ"<<endl;
for(int i=0; i<=l ;i++)
cout<<" ";
cout<<"λ"<<endl;
for(int i=0; i<=p ;i++)
cout<<" ";
cout<<"π"<<endl;
system("pause");
goto re;
playout:
system("pause");
return 0;
}
複製代碼
作者:
李知易
時間:
2015-7-18 11:56
本帖最後由 李知易 於 2015-8-29 11:06 編輯
#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");
srand(time(NULL));
cout<<"[馬到成功\] 賽馬場 第"<<n<<"場"<<endl;
cout<<"--------------------------------------------------------------------------|終點"<<endl;
cout<<"#1"<<endl;
cout<<"#2"<<endl;
cout<<"#3"<<endl;
cout<<"#4"<<endl;
cout<<endl;
cout<<"#1: 閃電"<<endl;
cout<<"#2: 傑哥"<<endl;
cout<<"#3: 內褲哥"<<endl;
cout<<"#4: 辣椒妹"<<endl;
cout<<endl;
system("pause");
system("cls");
while(a<=35 && c<=35 && b<=35 && d<=35)
{
r=rand()%4+1;
if(r==1)
a++;
else if(r==2)
b++;
else if(r==3)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------|終點"<<endl;
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");
}
if(a>=35)
{
cout<<"比賽結束 #1 閃電 贏了"<<endl;
}
else if(b>=35)
{
cout<<"比賽結束 #2 傑哥 贏了"<<endl;
}
else if(c>=35)
{
cout<<"比賽結束 #3 內褲哥 贏了"<<endl;
}
else
{
cout<<"比賽結束 #4 辣椒妹 贏了"<<endl;
}
cout<<"--------------------------------------------------------------------------|終點"<<endl;
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;
cout<<endl;
cout<<"#1: 閃電"<<endl;
cout<<"#2: 傑哥"<<endl;
cout<<"#3: 內褲哥"<<endl;
cout<<"#4: 辣椒妹"<<endl;
cout<<endl;
n++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
謝瀞儀
時間:
2015-7-18 12:15
ok
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
first:
int money,join,gambling,a=0;
cout<<"Do you want to join the casino?(1)Yes (2)No";
cin>>join;
if(join==1)
goto re;
else
{
cout<<"There has no chose of"<<"''"<<join<<"''.";
goto first;
}
re:
system("cls");
int x=0,b=0,g=0,u=0,l=0,p=0,r;
cout<<"How much money would you pay?";
cin>>money;
if(money<0)
{
cout<<"You did not pay the correct number.";
goto re;
}
srand(time(NULL));
a++;
cout<<"「Greece letter Casino」Race court No."<<a<<"roll"<<endl;
cout<<"---------------------------------------------------------|FIN"<<endl;
cout<<"χ"<<endl;
cout<<"β"<<endl;
cout<<"γ"<<endl;
cout<<"μ"<<endl;
cout<<"λ"<<endl;
cout<<"π"<<endl;
choose:
cout<<endl<<"Who would you gambling?(1)χ (2)β (3)γ (4)μ (5)λ (6)π";
cin>>gambling;
if(gambling<1 or gambling>6)
{
cout<<"There is no chose of"<<"''"<<gambling<<"''.";
goto choose;
}
else
goto down;
down:
system("pause");
if(gambling==1)
gambling==x;
else if(gambling==2)
gambling==b;
else if(gambling==3)
gambling==g;
else if(gambling==4)
gambling==u;
else if(gambling==5)
gambling==l;
else
gambling==p;
while(x<=55 and b<=55 and g<=55 and u<=55 and l<=55 and p<=55)
{
r=rand()%6+1;
if(r==1)
x++;
else if(r==2)
b++;
else if(r==3)
g++;
else if(r==4)
u++;
else if(r==5)
l++;
else
p++;
cout<<"「Greece letter Casino」Race court No."<<a<<"roll GAME ON"<<endl;
cout<<"---------------------------------------------------------|FIN"<<endl;
for(int i=0 ;i<=x ;i++)
cout<<" ";
cout<<"χ"<<endl;
for(int i=0 ;i<=b ;i++)
cout<<" ";
cout<<"β"<<endl;
for(int i=0 ;i<=g; i++)
cout<<" ";
cout<<"γ"<<endl;
for(int i=0 ;i<=u; i++)
cout<<" ";
cout<<"μ"<<endl;
for(int i=0; i<=l ;i++)
cout<<" ";
cout<<"λ"<<endl;
for(int i=0; i<=p ;i++)
cout<<" ";
cout<<"π"<<endl;
system("cls");
}
cout<<"「Greece letter Casino」Race court No."<<a<<"roll GAME OVER, ";
if(x==56)
cout<<"χ";
else if(b==56)
cout<<"β";
else if(g==56)
cout<<"γ";
else if(u==56)
cout<<"μ";
else if(l==56)
cout<<"λ";
else
cout<<"π";
cout<<"win!"<<endl;
cout<<"---------------------------------------------------------|FIN"<<endl;
for(int i=0 ;i<=x ;i++)
cout<<" ";
cout<<"χ"<<endl;
for(int i=0 ;i<=b ;i++)
cout<<" ";
cout<<"β"<<endl;
for(int i=0 ;i<=g; i++)
cout<<" ";
cout<<"γ"<<endl;
for(int i=0 ;i<=u; i++)
cout<<" ";
cout<<"μ"<<endl;
for(int i=0; i<=l ;i++)
cout<<" ";
cout<<"λ"<<endl;
for(int i=0; i<=p ;i++)
cout<<" ";
cout<<"π"<<endl;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
梁和雋
時間:
2015-8-1 10:45
#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<<"[gogo] 賽馬場 第"<<n<<"場"<<endl;
cout<<"--------------------------------------------------------------------------|終點"<<endl;
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
cout<<"4"<<endl;
cout<<endl;
cout<<"1: AA"<<endl;
cout<<"2: AS"<<endl;
cout<<"3: AD"<<endl;
cout<<"4: AF"<<endl;
cout<<endl;
system("pause");
system("cls");
while(a<=35 && c<=35 && b<=35 && d<=35)
{
r=rand()%4+1;
if(r==1)
a++;
else if(r==2)
b++;
else if(r==3)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------|終點"<<endl;
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");
}
if(a>=35)
{
cout<<"比賽結束 1贏了"<<endl;
}
else if(b>=35)
{
cout<<"比賽結束 2贏了"<<endl;
}
else if(c>=35)
{
cout<<"比賽結束 3贏了"<<endl;
}
else
{
cout<<"比賽結束 4贏了"<<endl;
}
cout<<"--------------------------------------------------------------------------|終點"<<endl;
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;
cout<<endl;
cout<<"#1: AA"<<endl;
cout<<"#2: AS"<<endl;
cout<<"#3: AD"<<endl;
cout<<"#4: AF"<<endl;
cout<<endl;
n++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
李大全
時間:
2015-8-1 10:46
#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<<"[gogo] 賽馬場 第"<<n<<"場"<<endl;
cout<<"--------------------------------------------------------------------------|終點"<<endl;
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
cout<<"4"<<endl;
cout<<endl;
cout<<"1: AA"<<endl;
cout<<"2: AS"<<endl;
cout<<"3: AD"<<endl;
cout<<"4: AF"<<endl;
cout<<endl;
system("pause");
system("cls");
while(a<=35 && c<=35 && b<=35 && d<=35)
{
r=rand()%4+1;
if(r==1)
a++;
else if(r==2)
b++;
else if(r==3)
c++;
else
d++;
cout<<"比賽進行中"<<endl;
cout<<"--------------------------------------------------------------------------|終點"<<endl;
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");
}
if(a>=35)
{
cout<<"比賽結束 1贏了"<<endl;
}
else if(b>=35)
{
cout<<"比賽結束 2贏了"<<endl;
}
else if(c>=35)
{
cout<<"比賽結束 3贏了"<<endl;
}
else
{
cout<<"比賽結束 4贏了"<<endl;
}
cout<<"--------------------------------------------------------------------------|終點"<<endl;
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;
cout<<endl;
cout<<"#1: AA"<<endl;
cout<<"#2: AS"<<endl;
cout<<"#3: AD"<<endl;
cout<<"#4: AF"<<endl;
cout<<endl;
n++;
system("pause");
goto re;
return 0;
}
複製代
複製代碼
作者:
洪振庭
時間:
2015-8-1 10:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1;
re:
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,z;
srand(time(NULL));
cout<<"1.Harry Poter "<<endl;
cout<<"2.Ron Weasley "<<endl;
cout<<"3.Cedric Diggory "<<endl;
cout<<"4.Draco Malfoy "<<endl;
cout<<"5.Cho Chang "<<endl;
cout<<"6.Fred Weasley "<<endl;
cout<<"7.George Weasley "<<endl;
cout<<"8.Ginny Weasley "<<endl;
system("pause");
system("cls");
cout<<"Broomstick fling a match of Hogwarts #"<<n<<endl;
cout<<"--------------------------------------------------------------------|win"<<endl;
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
cout<<"4"<<endl;
cout<<"5"<<endl;
cout<<"6"<<endl;
cout<<"7"<<endl;
cout<<"8"<<endl;
system("pause");
system("cls");
while(a<=65 && b<=65 && c<=65 && d<=65 && e<=65 && f<=65 && g<=65 && h<=65)
{
z=rand()%8+1;
if(z==1)
a++;
else if(z==2)
b++;
else if(z==3)
c++;
else if(z==4)
d++;
else if(z==5)
e++;
else if(z==6)
f++;
else if(z==7)
g++;
else
h++;
cout<<"RUN"<<endl;
cout<<"------------------------------------------------------------------|win"<<endl;
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;
for(int i=0;i<=e;i++)
cout<<" ";
cout<<"5"<<endl;
for(int i=0;i<=f;i++)
cout<<" ";
cout<<"6"<<endl;
for(int i=0;i<=g;i++)
cout<<" ";
cout<<"7"<<endl;
for(int i=0;i<=h;i++)
cout<<" ";
cout<<"8"<<endl;
system("cls");
}
cout<<"over"<<endl;
cout<<"--------------------------------------------------------------------|win"<<endl;
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;
for(int i=0;i<=e;i++)
cout<<" ";
cout<<"5"<<endl;
for(int i=0;i<=f;i++)
cout<<" ";
cout<<"6"<<endl;
for(int i=0;i<=g;i++)
cout<<" ";
cout<<"7"<<endl;
for(int i=0;i<=h;i++)
cout<<" ";
cout<<"8"<<endl;
if(a==65)
cout<<"Harry Poter win"<<endl;
else if(b==65)
cout<<"Ron Weasley win"<<endl;
else if(c==65)
cout<<"Cedric Diggory win"<<endl;
else if(d==65)
cout<<"Draco Malfoy win"<<endl;
else if(e==65)
cout<<"Cho Chang win"<<endl;
else if(f==65)
cout<<"Fred Weasley win"<<endl;
else if(g==65)
cout<<"George Weasley win"<<endl;
else
cout<<"Ginny Weasley win"<<endl;
n++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
洪振庭
時間:
2015-8-1 11:22
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n=1;
re:
system("cls");
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,z;
srand(time(NULL));
cout<<"1.Harry Poter "<<endl;
cout<<"2.Ron Weasley "<<endl;
cout<<"3.Cedric Diggory "<<endl;
cout<<"4.Draco Malfoy "<<endl;
cout<<"5.Cho Chang "<<endl;
cout<<"6.Fred Weasley "<<endl;
cout<<"7.George Weasley "<<endl;
cout<<"8.Ginny Weasley "<<endl;
system("pause");
system("cls");
cout<<"Broomstick fling a match of Hogwarts #"<<n<<endl;
cout<<"--------------------------------------------------------------------|win"<<endl;
cout<<"1"<<endl;
cout<<"2"<<endl;
cout<<"3"<<endl;
cout<<"4"<<endl;
cout<<"5"<<endl;
cout<<"6"<<endl;
cout<<"7"<<endl;
cout<<"8"<<endl;
system("pause");
system("cls");
while(a<=65 && b<=65 && c<=65 && d<=65 && e<=65 && f<=65 && g<=65 && h<=65)
{
z=rand()%8+1;
if(z==1)
a++;
else if(z==2)
b++;
else if(z==3)
c++;
else if(z==4)
d++;
else if(z==5)
e++;
else if(z==6)
f++;
else if(z==7)
g++;
else
h++;
cout<<"RUNNING"<<endl;
cout<<"------------------------------------------------------------------|win"<<endl;
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;
for(int i=0;i<=e;i++)
cout<<" ";
cout<<"5"<<endl;
for(int i=0;i<=f;i++)
cout<<" ";
cout<<"6"<<endl;
for(int i=0;i<=g;i++)
cout<<" ";
cout<<"7"<<endl;
for(int i=0;i<=h;i++)
cout<<" ";
cout<<"8"<<endl;
system("cls");
}
cout<<"over"<<endl;
cout<<"--------------------------------------------------------------------|win"<<endl;
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;
for(int i=0;i<=e;i++)
cout<<" ";
cout<<"5"<<endl;
for(int i=0;i<=f;i++)
cout<<" ";
cout<<"6"<<endl;
for(int i=0;i<=g;i++)
cout<<" ";
cout<<"7"<<endl;
for(int i=0;i<=h;i++)
cout<<" ";
cout<<"8"<<endl;
if(a==66)
cout<<"Harry Poter win"<<endl;
else if(b==66)
cout<<"Ron Weasley win"<<endl;
else if(c==66)
cout<<"Cedric Diggory win"<<endl;
else if(d==66)
cout<<"Draco Malfoy win"<<endl;
else if(e==66)
cout<<"Cho Chang win"<<endl;
else if(f==66)
cout<<"Fred Weasley win"<<endl;
else if(g==66)
cout<<"George Weasley win"<<endl;
else
cout<<"Ginny Weasley win"<<endl;
n++;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2