- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int round = 1;
- int buy=0,play,balance=0,option,player;
- srand(time(NULL));
- string shape[] = { "◆","★","▲","●" };
- re:
- cout<<"你的餘額:"<<balance<<endl;
- cout<<"買入<1> 下注<2> 不玩了<3>"<<endl;
- cin>>option;
- if(option==1)
- {
- cout<<"輸入金額:";
- cin>>buy;
- if(buy<=0)
- {
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- system("cls");
- goto re;
- }
- balance+=buy;
- buy=0;
- goto re;
- }
- else if(option==2)
- {
- cout<<"下注金額:";
- cin>>buy;
- play+=buy;
- balance-=buy;
- if(buy<=0)
- {
- cout<<"餘額不足"<<endl;
- _sleep(1500);
- system("cls");
- goto re;
- }
- if(buy<=0)
- {
- cout<<"輸入錯誤"<<endl;
- _sleep(1500);
- system("cls");
- goto re;
- }
- cout<<"請選擇馬匹:◆<1>★<2>▲<3>●<4>";
- cin>>player;
- }
- else
- {
- cout<<"已退出遊戲,你的餘額為:"<<balance<<endl;
- _sleep(3000);
- return 0;
- }
- int steps[] = {0,0,0,0};
- cout<<"第"<<round<<"局"<<endl;
- cout << "超坑錢賽馬場" << endl;
- cout << "-------------------------------------------------------------------------|終點";
- _sleep(2000);
- int w = 0;int plus;
- while (w <= 71)
- {
- cout << "比賽進行中" << endl;
- cout << "-------------------------------------------------------------------------|終點" << endl;
- steps[rand() % 4] += 1;
- w = steps[rand() % 4];
- for (int s = 0;s <= steps[0];s++)
- cout << " ";
- cout << shape[0] << endl;
- for (int s = 0;s <= steps[1];s++)
- cout << " ";
- cout << shape[1] << endl;;
- for (int s = 0;s <= steps[2];s++)
- cout << " ";
- cout << shape[2] << endl;
- for (int s = 0;s <= steps[3];s++)
- cout << " ";
- cout << shape[3] << endl;
- _sleep(10);
- if (w ==71)
- {
- round++;
- cout<<"由"<<shape[rand() % 4]<<"獲勝" <<endl;
- _sleep(1000);
- if((rand()%4)+1==player)
- {
- balance+=buy*100;
- system("pause");
- goto re;
- }
- cout<<"什麼?你沒有賭注他?"<<endl;
- buy==0;
- goto re;
- }
- system("cls");
- }
- }
複製代碼 |