- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main(){
- int x,y;
- int n[]={0,0,0,0};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬程式"<<endl;
- cout<<"---------------------------------------------------------------|終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- re:
- if(n[0]<70&&n[1]<70&&n[2]<70&&n[3]<73){
- system("cls");
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------|終點"<<endl;
- int speed=2;
- int i;
- x=rand()%4;
- n[x]++;
- for(int i=1;i<=n[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1;i<=n[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1;i<=n[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1;i<=n[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- _sleep(speed);
- goto re;
- }
- else{
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------|終點"<<endl;
- for(int i=1;i<=n[0];i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=1;i<=n[1];i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=1;i<=n[2];i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=1;i<=n[3];i++)
- cout<<" ";
- cout<<"●"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |