本帖最後由 林少謙 於 2024-7-27 16:09 編輯
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int x,y,t=1;
- re2:
- int a[]{0,0,0,0};
- string b[]{"◆","★","▲","●"};
- cout<<"空蕩蕩賽馬場 第"<<t<<"場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- re:
- if(a[0]<73&&a[1]<73&&a[2]<73&&a[3]<73)
- {
- system("cls");
- cout<<"比賽開始"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=3; i++)
- {
- x=rand()%5+1;
- a[i]+=x;
- }
- for(int i=1; i<=a[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=a[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=a[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=a[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- _sleep(100);
- goto re;
- }
- else
- {
- if(a[0]>=73)
- y=0;
- if(a[1]>=73)
- y=1;
- if(a[2]>=73)
- y=2;
- if(a[3]>=73)
- y=3;
- system("cls");
- cout<<"比賽結束由"<<b[y]<<"獲勝"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=1; i<=a[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1; i<=a[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1; i<=a[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1; i<=a[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- }
- system("pause");
- t+=1;
- goto re2:
- return 0;
- }
複製代碼 |