- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main(){
- int z=1;
- int x,y;
- re1:
- int n[]={0,0,0,0};
- system("cls");
- 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<<"比賽進行中 第"<<z<<"局"<<endl;
- cout<<"-------------------------------------------------------------------|終點"<<endl;
- int speed=0.01;
- 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");
- if(n[0]>=70)
- cout<<"由◆勝出,";
- else if(n[1]>=70)
- cout<<"由★勝出,";
- else if(n[2]>=70)
- cout<<"由▲勝出,";
- else if(n[3]>=70)
- cout<<"由●勝出,";
- 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;
- }
- z++;
- system("pause");
- goto re1;
- return 0;
- }
複製代碼 |