- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main(){
-
- int round=1;
- int balance=0;
- int money=0;
- int betmoney=0;
- int player=0;
- int moneylost=0;
- int moneygained=0;
- re:
- system("cls");
- srand(time(NULL));
- string p[]={"◆","★","▲","●"};
- int s[]={0,0,0,0};
- int r=0;
- int choice;
- cout<<"歡迎光臨騙你錢賽馬場 | 賽馬第"<<round<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- cout<<p[i]<<endl;
-
- cout<<endl<<"可用餘額: "<<balance<<"元"<<endl<<endl;
- cout<<"(1)買入(儲值) (2)下注 (3)離開 請選擇:";
- cin>>choice;
-
- if(choice==1){
- cout<<"請問要加值多少錢:";
- cin>>money;
- if(money<=0){
- cout<<"輸入錯誤,請重新輸入!"<<endl;
- _sleep(1500);
- goto re;
- }else
- balance=balance+money;
- goto re;
- }else if(choice==2){
- cout<<"請問要下注多少錢:";
- cin>>betmoney;
- if (betmoney<=0 or betmoney>balance){
- cout<<"輸入錯誤,請重新輸入!"<<endl;
- _sleep(1500);
- goto re;
- }else{
- cout<<"(1)◆(2)★(3)▲(4)●請選擇:";
- }
- cin>>player;
- if (player==1 or player==2 or player==3 or player==4){
- cout<<"比賽即將開始"<<endl;
- _sleep(2000);
-
- }else{
- cout<<"輸入錯誤,請重新輸入!"<<endl;
- _sleep(1500);
- goto re;
- }
- }
-
- if(choice == 3){
- if (moneylost>0 and moneylost>moneygained){
- cout<<"不好意思!讓你損失了"<<moneylost-moneygained<<"元!"<<endl;
- cout<<"歡迎下次再來!"<<endl;
- }else if (moneygained>0 and moneylost<moneygained){
- cout<<"恭喜你!這次總共贏了"<<moneygained-moneylost<<"元!"<<endl;
- cout<<"歡迎下次再來!"<<endl;
- }else if (moneygained=moneylost){
- cout<<"沒輸沒贏!全身而退!"<<endl;
- cout<<"歡迎下次再來!"<<endl;
- }else{
- cout<<"歡迎下次再來!"<<endl;
- }
- system("pause");
- return 0;
- }
-
-
-
- system("pause");
- system("cls");
- while(s[r]<=73)
- {
- r=rand()%4; //0~3
- 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;
- }
- system("cls");
- }
- cout<<"比賽結束!由"<<p[r]<<"獲勝!"<<endl;
- if (player-1 == r){
- cout<<"你下注的馬贏了!恭喜你贏得"<< betmoney*3<<"元!"<<endl;
- balance+=betmoney*2;
- moneygained+=betmoney*2;
- }else{
- moneylost+=betmoney;
- balance-=betmoney;
- cout<<"你下注的馬輸了!, 損失"<<betmoney<<"元"<<endl;
- }
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- round++;
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |