標題:
賽馬程式 (五)
[打印本頁]
作者:
陳品肇
時間:
2022-3-26 11:21
標題:
賽馬程式 (五)
本帖最後由 陳品肇 於 2022-3-26 12:04 編輯
[attach]12906[/attach]
[attach]12907[/attach]
1. 完成主選單的主要架構 (運用if...else if...else判斷式)
2. 新增 (2)下注 功能
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// 開局第一場
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ; // 每匹馬前進的進度
// 當有任一匹跑到終點70 的時候就跳離迴圈
string words ="賽馬進行中";
// 代表馬的名子
string name[4] = {"◆","★","▲","●"};
// 宣告一個暫存的變數
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
// 如果買入 把錢加入餘額
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
// 離開
goto end;
}
system("pause"); // 按下enter 才開始
system("cls"); // 清空畫面
srand(time(NULL)); // 撒種子亂數
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
// 隨機挑一匹馬
r = rand()%4+1;
// 每匹馬 跑的進度
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
// 要把每匹馬的進度給輸出
// 第一匹馬
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
// 第二匹馬
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
// 第三匹馬
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
// 第四匹馬
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
// 當有任一個跑到71 就代表到終點 不要清空畫面
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls"); // 清空畫面
}
}
// 局數+1
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
許宸瑀
時間:
2022-3-26 12:01
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
}
system("pause");
goto re;
}else
{
}
system("pause");
system("cls");
srand(time(NULL));
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
郭博鈞
時間:
2022-3-26 12:03
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1 blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r,opition,buyin=0,bet,horse;
cout<<"賽馬場 第"<<n<<"局"<<endl;
cout<<"-----------------------------------------------------------------終點"<<endl;
cout<<"Ⅰ"<<endl;
cout<<"Ⅱ"<<endl;
cout<<"Ⅲ"<<endl;
cout<<"Ⅳ"<<endl;
cout<<endl;
cout<<"可用餘額"<<blance<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>opition;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet>blance)
{
cout<<"你餘額不足"
system("pause");
system("cls");
srand(time(NULL));
int a=0,b=0,c=0,d=0,r,opition,buyin;
string words ="賽馬進行中";
string name[4]={"Ⅰ","Ⅱ","Ⅲ","Ⅳ"};
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
int position;
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束,由"+name[position]+"奪魁";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
system("cls");
goto re;
return 0;
}
複製代碼
作者:
柳侑辰
時間:
2022-3-26 12:06
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int t=0,z=0;
re:
system("cls");
t++;
int a=0,b=0,c=0,d=0,r,tmp=0,o,buy=0,bet,horse;
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
cout<<"「好事成雙」賽馬場"<<"第"<<t<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl<<endl;
cout<<"可用餘額:"<<z<<"元"<<endl<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>o;
if(o==1)
{
cout<<"買入:";
cin>>buy;
z += buy;
goto re;
}else if(o==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > z)
{
cout<<"您餘額不足,請重新下注!"<<endl;
}else if(bet >0 && bet<=z)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
z -= bet;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
}
system("pause");
goto re;
}else
{
goto end;
}
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
tmp = b==70 ? 1 :0;
tmp = c==70 ? 2 :0;
tmp = d==70 ? 3 :0;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
tmp = 0;
if(b==70)
tmp =1;
if(c==70)
tmp =2;
if(d==70)
tmp =3;
words = "比賽結束!由"+name[tmp]+"先馳得點!";;
}
if(a==71 || b==71 || c==71 || d==71)
{
}else
{
system("cls");
}
}
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
田家齊
時間:
2022-3-26 12:07
本帖最後由 田家齊 於 2022-4-2 10:41 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
goto end;
}
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
徐譽豈
時間:
2022-3-26 12:10
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r,option,buyin =0,bet,horse;
cout<<"日本東京競馬場<東京優駿>[2400m草地]"<<endl;
cout<< "----------------------------------------------------------------------|goal"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元" <<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
} else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance == bet;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
}
system("pause");
goto re;
}else
{
}
system("pause");
system("cls");
srand(time(NULL));
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position = 1;
if(c==70)
position = 2;
if(d==70)
position = 3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-3-26 15:50
本帖最後由 高昀昊 於 2022-3-26 15:52 編輯
老師,我先全部做完了喔
(而且不知道為什麼複製貼上之後縮排會有點跑掉)
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0 ,pay ,choose ;
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
back:
cout<<"(1)買入 (2)下注 (3)純粹觀賽 (4)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>pay;
if(pay>blance)
{
cout<<"您餘額不足,請重新下注"<<endl;
system("pause");
goto back;
}
if(pay<=0)
{
cout<<"輸入錯誤"<<endl;
goto back;
}
cout<<"(1)◆ (2)★ (3)▲ (4)● (5)離開 請選擇:";
cin>>choose;
if(choose==1)
{
}else if(choose==2)
{
}else if(choose==3)
{
}else if(choose==4)
{
}else if(choose==5)
{
goto back;
}else {
cout<<"輸入錯誤"<<endl;
goto back;
}
blance-=pay;
}else if(option==3)
{
goto play;
}else if(option==4)
{
goto end;
}else{
cout<<"輸入錯誤"<<endl;
goto back;
}
play:
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
if(a==70)
{
a++;
goto over;
}
if(b==70)
{
b++;
goto over;
}
if(c==70)
{
c++;
goto over;
}
if(d==70)
{
d++;
goto over;
}
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
over:
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
if(option==3)
goto keep;
if(position==0)
{
if(choose==1)
{
cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
blance+=4*pay;
}else{
cout<<"可惜,你輸了,再接再厲"<<endl;
}
}else if(position==1)
{
if(choose==2)
{
cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
blance+=4*pay;
}else{
cout<<"可惜,你輸了,再接再厲"<<endl;
}
}else if(position==2)
{
if(choose==3)
{
cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
blance+=4*pay;
}else{
cout<<"可惜,你輸了,再接再厲"<<endl;
}
}else if(position==3)
{
if(choose==4)
{
cout<<"恭喜,你賭贏了,獲得4倍的獎金"<<endl;
blance+=4*pay;
}else{
cout<<"可惜,你輸了,再接再厲"<<endl;
}
}
}else{
system("cls");
}
}
keep:
n++;
system("pause");
goto re;
end:
return 0;
}
複製代碼
作者:
孫子傑
時間:
2022-4-1 22:03
[code]#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// 開局第一場
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ; // 每匹馬前進的進度
// 當有任一匹跑到終點70 的時候就跳離迴圈
string words ="賽馬進行中";
// 代表馬的名子
string name[4] = {"◆","★","▲","●"};
// 宣告一個暫存的變數
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
// 如果買入 把錢加入餘額
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
// 離開
goto end;
}
system("pause"); // 按下enter 才開始
system("cls"); // 清空畫面
srand(time(NULL)); // 撒種子亂數
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
// 隨機挑一匹馬
r = rand()%4+1;
// 每匹馬 跑的進度
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
// 要把每匹馬的進度給輸出
// 第一匹馬
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
// 第二匹馬
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
// 第三匹馬
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
// 第四匹馬
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
[/code]
作者:
林鴻慶
時間:
2022-4-2 10:13
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
}
system("pause");
goto re;
}else
{
}
system("pause");
system("cls");
srand(time(NULL));
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
system("pause");
return 0;
}
複製代碼
作者:
林紘憲
時間:
2022-4-2 10:13
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// 開局第一場
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ; // 每匹馬前進的進度
// 當有任一匹跑到終點70 的時候就跳離迴圈
string words ="賽馬進行中";
// 代表馬的名子
string name[4] = {"◆","★","▲","●"};
// 宣告一個暫存的變數
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
// 如果買入 把錢加入餘額
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
// 離開
goto end;
}
system("pause"); // 按下enter 才開始
system("cls"); // 清空畫面
srand(time(NULL)); // 撒種子亂數
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
// 隨機挑一匹馬
r = rand()%4+1;
// 每匹馬 跑的進度
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
// 要把每匹馬的進度給輸出
// 第一匹馬
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
// 第二匹馬
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
// 第三匹馬
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
// 第四匹馬
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
// 當有任一個跑到71 就代表到終點 不要清空畫面
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls"); // 清空畫面
}
}
// 局數+1
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
鍾易澄
時間:
2022-4-2 10:13
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// 開局第一場
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ; // 每匹馬前進的進度
// 當有任一匹跑到終點70 的時候就跳離迴圈
string words ="賽馬進行中";
// 代表馬的名子
string name[4] = {"◆","★","▲","●"};
// 宣告一個暫存的變數
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
// 如果買入 把錢加入餘額
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
// 離開
goto end;
}
system("pause"); // 按下enter 才開始
system("cls"); // 清空畫面
srand(time(NULL)); // 撒種子亂數
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
// 隨機挑一匹馬
r = rand()%4+1;
// 每匹馬 跑的進度
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
// 要把每匹馬的進度給輸出
// 第一匹馬
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
// 第二匹馬
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
// 第三匹馬
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
// 第四匹馬
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
// 當有任一個跑到71 就代表到終點 不要清空畫面
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls"); // 清空畫面
}
}
// 局數+1
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
高鋐鈞
時間:
2022-4-2 10:16
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
goto end;
}
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
許馹東
時間:
2022-4-2 10:39
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
goto end;
}
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
曾善勤
時間:
2022-4-2 10:40
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0,bet,horse ;
string words ="賽馬進行中";
string name[4] = {"◆","★","▲","●"};
int position =0;
cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(option==2)
{
cout<<"請下注:";
cin>>bet;
if(bet > blance)
{
cout<<"您餘額不足,請重新下注!"<<endl;
system("pause");
goto re;
}else if(bet >0 && bet<=blance)
{
cout<<"(1)◆ (2)★ (3)▲(4)●請選擇:";
cin>>horse;
blance -= bet;
cout<<"即將開始賽馬!"<<endl;
}else
{
cout<<"您輸入錯誤,請重新下注!"<<endl;
system("pause");
goto re;
}
}else
{
goto end;
}
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束!由"+name[position]+"先馳得點!";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
作者:
郭博鈞
時間:
2022-4-2 11:11
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1,blance=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r,opition,buyin,bet,horse;
string words ="賽馬進行中";
string name[4]={"Ⅰ","Ⅱ","Ⅲ","Ⅳ"};
int position =0;
cout<<"賽馬場 第"<<n<<"局"<<endl;
cout<<"-----------------------------------------------------------------終點"<<endl;
cout<<"Ⅰ"<<endl;
cout<<"Ⅱ"<<endl;
cout<<"Ⅲ"<<endl;
cout<<"Ⅳ"<<endl;
cout<<endl;
cout<<"可用餘額"<<blance<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>opition;
if(opition==1)
{
cout<<"買入:";
cin>>buyin;
blance += buyin;
goto re;
}else if(opition==2)
{
cout<<"下注金額:";
cin>>bet;
if(bet>blance)
{
cout<<"餘額不足 請重新下注"<<endl;
system("pause");
goto re;
}else if(bet>0 && blance>=bet)
{
cout<<"請選擇 (1)Ⅰ (2)Ⅱ (3)Ⅲ (4)Ⅳ"<<endl;
cin>>horse;
blance-=bet;
cout<<"即將開始賽馬"<<endl;
}else
{
cout<<"輸入錯誤 請重新輸入"<<endl;
system("pause");
goto re;
}
}else
{
goto end;
}
system("pause");
system("cls");
srand(time(NULL));
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4+1;
switch(r)
{
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
case 4:
d++;
break;
}
for(int i=0;i<=a;i++)
{
cout<<" ";
}
cout<<name[0]<<endl;
for(int i=0;i<=b;i++)
{
cout<<" ";
}
cout<<name[1]<<endl;
for(int i=0;i<=c;i++)
{
cout<<" ";
}
cout<<name[2]<<endl;
for(int i=0;i<=d;i++)
{
cout<<" ";
}
cout<<name[3]<<endl;
if(a==70 || b==70 || c==70 || d==70)
{
int position;
if(a==70)
position = 0;
if(b==70)
position =1;
if(c==70)
position =2;
if(d==70)
position =3;
words = "比賽結束,由"+name[position]+"奪魁";
}
if(a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
n++;
system("pause");
goto re;
end:
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2