- #include<iostream>
- #include<ctime>
- using namespace std;
- int main()
- {
- int e=0;
- int b,d,g,h,money=0;
- srand(time(NULL));
- re:
- e++;
- start:
- system("cls");
- int a[4]= {0,0,0,0};
- string j[4]= {"△","▲","☆","★"};
- cout<<"賽馬場"<<"第"<<e<<"局"<<endl;
- cout<<"---------------------------------------------------------|終點"<<endl;//57
- cout<<"△"<<endl;
- cout<<"▲"<<endl;
- cout<<"☆"<<endl;
- cout<<"★"<<endl;
- cout<<endl<<endl<<"你的餘額:"<<money<<endl;
- cout<<"[1]買入[2]下注[3]離開:";
- cin>>d;
- if(d==1)
- {
- cout<<"你要買入多少錢?:";
- cin>>b;
- if(b<0)
- {
- cout<<"輸入錯誤";
- _sleep(1500);
- goto start;
- }
- money+=b;
- goto start;
- }
- if(d==2)
- {
- cout<<"下注:";
- cin>>g;
- if(g>money)
- {
- cout<<"輸入錯誤";
- _sleep(1500);
- goto start;
- }
- if(g<0)
- {
- cout<<"輸入錯誤";
- _sleep(1500);
- goto start;
- }
- cout<<"請選擇1△ 2▲ 3☆ 4★: ";
- cin>>h;
- }
- system("pause");
- system("cls");
- while(true)
- {
- system("cls");
- int c=rand()%4;
- if(a[c]>=57)
- {
- cout<<"賽馬場"<<"第"<<e<<"局"<<"由"<<j[c]<<"先馳得點"<<endl;
- break;
- }
- cout<<"賽馬場"<<"第"<<e<<"局"<<endl;
- cout<<"---------------------------------------------------------|終點"<<endl;
- a[c]+=3;
- for(int m=1; m<=a[0]; m++)
- cout<<" ";
- cout<<"△"<<endl;
- for(int m=1; m<=a[1]; m++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int m=1; m<=a[2]; m++)
- cout<<" ";
- cout<<"☆"<<endl;
- for(int m=1; m<=a[3]; m++)
- cout<<" ";
- cout<<"★"<<endl;
- _sleep(50);
- }
- cout<<"---------------------------------------------------------|終點"<<endl;
- for(int m=1; m<=a[0]; m++)
- cout<<" ";
- cout<<"△"<<endl;
- for(int m=1; m<=a[1]; m++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int m=1; m<=a[2]; m++)
- cout<<" ";
- cout<<"☆"<<endl;
- for(int m=1; m<=a[3]; m++)
- cout<<" ";
- cout<<"★"<<endl;
- system("pause");
- system("cls");
- goto re;
- return 0;
- }
複製代碼 |