本帖最後由 許宸瑀 於 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;
- }
複製代碼 |