標題:
賽馬程式 (四)
[打印本頁]
作者:
陳品肇
時間:
2022-3-26 10:16
標題:
賽馬程式 (四)
本帖最後由 陳品肇 於 2022-3-26 11:54 編輯
加入首頁選單, 新增買入的功能, 執行畫面如下:
可用餘額: 0 元
(1)買入 (2)下注 (3)離開 請選擇: 1
買入: 200
在使用者輸入數值後, 畫面更新如下:
可用餘額: 200 元
(1)買入 (2)下注 (3)離開 請選擇:
#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 ; // 每匹馬前進的進度
// 當有任一匹跑到終點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;
}
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;
return 0;
}
複製代碼
作者:
許宸瑀
時間:
2022-3-26 11:18
本帖最後由 許宸瑀 於 2022-3-26 11:30 編輯
#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 ;
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;
}
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");
system("cls");
goto re;
return 0;
}
複製代碼
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
int a=0,b=0,c=0,d=0,r, option, buyin =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;
}
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");
system("cls");
goto re;
return 0;
}
複製代碼
作者:
曾善勤
時間:
2022-3-26 11:20
本帖最後由 曾善勤 於 2022-3-26 11:26 編輯
#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 ;
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;
}
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 11:21
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// 開局第一場
int n =1,blance=0;
re:
int a=0,b=0,c=0,d=0,r, option, buyin =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;
}
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");
system("cls");
goto re;
return 0;
}
複製代碼
作者:
孫子傑
時間:
2022-3-26 11:25
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1,x=0;
re:
system("cls");
int a=0,b=0,c=0,d=0,r, option, buyin =0 ;
cout<<"「智慧」賽馬場 第"<<n<<"局"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<x<<"元"<<endl;
cout<<endl;
cout<<"(1)買入 (2)下注 (3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
x += buyin;
goto re;
}
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 11:26
#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 ;
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;
}
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 11:29
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int x=1,blance=0,option=0,buyin=0;
string name[4]={"◆","★","▲","●"};
re:
system("cls");
cout<<"「好事成雙」賽馬場"<<"第"<<x<<"局"<<endl;
cout<<"------------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<endl;
cout<<"可用餘額:"<<blance<<"元"<<endl;
cout<<"(1)買入(2)下注(3)離開 請選擇:";
cin>>option;
if(option==1)
{
cout<<"買入:";
cin>>buyin;
blance+=buyin;
goto re;
}
system("pause");
system("cls");
srand(time(NULL));
int a=0,b=0,c=0,d=0,r,z=0;
string words ="賽馬進行中";
while(a<=70 && b<=70 && c<=70 && d<=70)
{
cout<<words<<"第"<<x<<"局"<<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<<"◆"<<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;
if(a==70 || b==70 || c==70 || d==70)
{
if(a==70)
z=0;
if(b==70)
z=1;
if(c==70)
z=2;
if(d==70)
z=3;
words = "賽馬完成,由"+name[z]+"先馳得點";
}
if( a==71 || b==71 || c==71 || d==71)
{
}else{
system("cls");
}
}
x++;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
柳侑辰
時間:
2022-3-26 11:29
#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;
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;
}
system("pause");
system("cls");
string name[4] = {"◆","★","▲","●"};
srand(time(NULL));
string words ="賽馬進行中";
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;
return 0;
}
複製代碼
作者:
林鴻慶
時間:
2022-3-26 11:31
#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 ;
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;
}
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 11:33
#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 ;
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;
}
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 11:33
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n=1 blance=0;
int a=0,b=0,c=0,d=0,r,opition,buyin;
re:
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;
}
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 11:35
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int n =1,blance=0;
re:
system("pause");
int a=0,b=0,c=0,d=0,r,option,buyin =0;
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;
}
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++;
goto re;
return 0;
}
複製代碼
作者:
柳侑辰
時間:
2022-3-26 11:53
#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;
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;
}
system("pause");
system("cls");
string name[4] = {"◆","★","▲","●"};
srand(time(NULL));
string words ="賽馬進行中";
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;
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-3-26 14:34
#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 ;
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;
}
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;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2