- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int n=1, balance=0;
- int option, buying, bet, player, all;
- re:
- system("cls");
- srand(time(NULL));
- int s[]={0,0,0,0};
- string p[]={"◆","★","▲","●"};
- int r=0;
- cout<<"本賽馬場 第"<<n<<"局"<<endl;
- cout<<"------------------------------------------------------------------------- 終點"<<endl;
- for(int i=0; i<4; i++){
- cout<<p[i]<<endl;
- }
- cout<<"可用餘額"<<balance<<"元"<<endl;
- cout<<"請選擇 (1)買入(2)下注(3)離開"<<endl;
- cin>>option;
- if(option==1){
- cout<<"買入 :"<<endl;
- cin>>buying;
- if(buying<=0){
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- balance+=buying;
- all+=buying;
- goto re;
- }
- else if(option==2){
- cout<<"下注 :"<<endl;
- cin>>bet;
- if(bet>balance){
- cout<<"餘額不足"<<endl;
- _sleep(1500);
- goto re;
- }
- if(bet<=0){
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- cout<<"請選擇 (1)◆ (2)★ (3)▲ (4)●"<<endl;
- cin>>player;
- cout<<"比賽即將開始"<<endl;
- }
- else if(option==3){
- goto end;
- }
- else{
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- goto re;
- }
- system("pause");
- system("cls");
- while(s[r]<=73){
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"------------------------------------------------------------------------- 終點"<<endl;
- for(int i=0; i<4; i++){
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- _sleep(50);
- system("cls");
- }
- cout<<"最終由"<<p[r]<<"先馳得點"<<endl;
- cout<<"比賽結束"<<endl;
- cout<<"------------------------------------------------------------------------- 終點"<<endl;
- for(int i=0; i<4; i++){
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- if(r+1==player){
- balance+=bet*3;
- cout<<"贏得"<<bet*3<<"元"<<endl;
- }
- else{
- balance-=bet;
- cout<<"損失"<<bet<<"元"<<endl;
- }
- system("pause");
- n++;
- goto re;
- end:
- if(all==balance){
- cout<<"沒輸沒贏"<<endl;
- }
- if(all<balance){
- cout<<"恭喜 這次賺了"<<balance-all<<"元"<<endl;
- }
- if(all>balance){
- cout<<"可惜 這次損失"<<all-balance<<"元"<<endl;
- }
- cout<<"慢走"<<endl;
- _sleep(1500);
- return 0;
- }
複製代碼 |