- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int x,y;
- int a[]{0,0,0,0};
- cout<<"空蕩蕩賽馬場"<<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
- {
- system("cls");
- cout<<"比賽結束"<<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");
- return 0;
- }
複製代碼 |