標題:
賽馬程式 (三)
[打印本頁]
作者:
歐柏罕
時間:
2017-10-24 18:29
標題:
賽馬程式 (三)
本帖最後由 歐柏罕 於 2017-10-24 18:49 編輯
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0, random=0;
int balance=0; //錢包
int option=0; //讓他做選擇 ,ABC => string
int buyin=0; //輸入的錢
while(option == 0 or option ==1) //第一次或是買入
{
srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽馬場 " << "第 " <<times << "局 "<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
}
system("pause");
system("cls");
}
while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
{
random=rand()%4; //產生0~3之隨機亂數
if(random==0) {
horse1++;
}
else if(random==1) {
horse2++;
}
else if(random==2) {
horse3++;
}
else if(random==3) {
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++;
system("cls");
cout<<"比賽結束! 由 ";
if(horse1 == 75) {
cout<< "◆" << "先馳得點" << endl;
}
else if (horse2 == 75) {
cout<< "★" << "先馳得點" << endl;
}
else if (horse3 == 75) {
cout<< "▲" << "先馳得點" << endl;
}
else if (horse4 == 75) {
cout<< "●" << "先馳得點" << endl;
}
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
顏羽彤
時間:
2017-10-24 18:41
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0,random=0,money=0,option=0,buyin=0;
while(option==0 || option==1)
{ srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽馬場 "<<"第"<<times<<"次"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"可用餘額:"<<money<<"元"<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:"<<endl;
cin>>option;
if(option=1)
{
cout<<"買入:";
cin>>buyin;
money=money+buyin;
}
system("pause");
system("cls");
}
while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
{
random=rand()%4; //產生0~3之隨機亂數
if(random==0)
{
horse1++;
}
else if(random==1)
{
horse2++;
}
else if(random==2)
{
horse3++;
}
else if(random==3)
{
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++;
cout<<"比賽結束 由";
if(horse1==75)
{
cout<<"◆";
}
if(horse2==75)
{
cout<<"★";
}
if(horse3==75)
{
cout<<"▲";
}
if(horse4==75)
{
cout<<"●";
}
cout<<"先馳得點!"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++)
{
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++)
{
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++)
{
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++)
{
cout<<" ";
}
cout<<"●"<<endl;
system("pause");
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
巫沛庭
時間:
2017-10-24 18:43
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=0;
while(true)
{
int horse1=0,horse2=0,horse3=0,horse4=0,random=0;
int money=0,buyin=0,choise=0;
system("cls");
while( choise== 0 or choise ==1)
{
srand(time(NULL));
system("cls");
cout<<"人山人海人見人愛 賽馬場"<<endl;
cout<<"---------------------------------------------|終點"<<endl;
cout<<"Q"<<endl;
cout<<"∮"<<endl;
cout<<"㊣"<<endl;
cout<<"♂"<<endl;
cout<<"可用餘額:"<<money<<"元"<<endl;
cout<<"(1)買入(2)下注(3)離開,請選擇:";
cin>>choise;
if(choise==1)
{
cout<<"請輸入價錢:";
cin>>buyin;
money=+buyin;
}
}
system("pause");
system("cls");
while(horse1!=45&&horse2!=45&&horse3!=45&&horse4!=45)
{
random=rand()%4;
if(random==0)
horse1++;
if(random==1)
horse2++;
if(random==2)
horse3++;
if(random==3)
horse4++;
cout<<"比賽進行中"<<endl;
cout<<"---------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++)
cout<<" ";
cout<<"Q"<<endl;
for(int i=1;i<=horse2;i++)
cout<<" ";
cout<<"∮"<<endl;
for(int i=1;i<=horse3;i++)
cout<<" ";
cout<<"㊣"<<endl;
for(int i=1;i<=horse4;i++)
cout<<" ";
cout<<"♂"<<endl;
system("cls");
}
times++;
cout<<"比賽結束!由";
if(horse1==45)
cout<<"Q獲勝~~"<<endl;
else if(horse2==45)
cout<<"∮獲勝~~"<<endl;
else if(horse3==45)
cout<<"㊣獲勝~~"<<endl;
else if(horse1=4==45)
cout<<"♂獲勝~~"<<endl;
cout<<"---------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++)
cout<<" ";
cout<<"Q"<<endl;
for(int i=1;i<=horse2;i++)
cout<<" ";
cout<<"∮"<<endl;
for(int i=1;i<=horse3;i++)
cout<<" ";
cout<<"㊣"<<endl;
for(int i=1;i<=horse4;i++)
cout<<" ";
cout<<"♂"<<endl;
system("pause");
}
system("pause");
return 0;
}
作者:
張閎鈞
時間:
2017-10-24 18:49
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0, random=0;
int balance=0; //錢包
int option=0; //讓他做選擇 ,ABC => string
int buyin=0; //輸入的錢
while(option == 0 or option ==1) //第一次或是買入
{
srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽馬場 " << "第 " <<times << "局 "<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
}
system("pause");
system("cls");
}
while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
{
random=rand()%4; //產生0~3之隨機亂數
if(random==0) {
horse1++;
}
else if(random==1) {
horse2++;
}
else if(random==2) {
horse3++;
}
else if(random==3) {
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++;
system("cls");
cout<<"比賽結束! 由 ";
if(horse1 == 75) {
cout<< "◆" << "先馳得點" << endl;
}
else if (horse2 == 75) {
cout<< "★" << "先馳得點" << endl;
}
else if (horse3 == 75) {
cout<< "▲" << "先馳得點" << endl;
}
else if (horse4 == 75) {
cout<< "●" << "先馳得點" << endl;
}
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("pause");
}
system("pause");
return 0;
}
複製代碼
作者:
張凱婷
時間:
2017-10-24 19:12
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
int times=1;
while(true)
{
int horse1=0, horse2=0, horse3=0, horse4=0, random=0;
int balance=0;
int option=0;
int buyin=0;
while(option == 0 or option ==1)
{
srand(time(NULL));
system("cls");
cout<<"「好事成雙」賽馬場 " << "第 " <<times << "局 "<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇: ";
cin>>option;
if(option==1)
{
cout<<"買入: ";
cin>>buyin;
balance+=buyin;
}
system("pause");
system("cls");
}
while(horse1!=75 && horse2!=75 && horse3!=75 && horse4!=75)
{
random=rand()%4;
if(random==0) {
horse1++;
}
else if(random==1) {
horse2++;
}
else if(random==2) {
horse3++;
}
else if(random==3) {
horse4++;
}
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("cls");
}
times++;
system("cls");
cout<<"比賽結束! 由 ";
if(horse1 == 75) {
cout<< "◆" << "先馳得點" << endl;
}
else if (horse2 == 75) {
cout<< "★" << "先馳得點" << endl;
}
else if (horse3 == 75) {
cout<< "▲" << "先馳得點" << endl;
}
else if (horse4 == 75) {
cout<< "●" << "先馳得點" << endl;
}
cout<<"------------------------------------------------------------------------| 終點"<<endl;
for(int i=1; i<=horse1; i++) {
cout<<" ";
}
cout<<"◆"<<endl;
for(int i=1; i<=horse2; i++) {
cout<<" ";
}
cout<<"★"<<endl;
for(int i=1; i<=horse3; i++) {
cout<<" ";
}
cout<<"▲"<<endl;
for(int i=1; i<=horse4; i++) {
cout<<" ";
}
cout<<"●"<<endl;
system("pause");
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2