- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a=0,b=0,c=0,d=0,r,winner;
- cout<<"李奧斯本 賽馬場"<<endl;
- cout<<"$-----------------------------------------------------------------||終點||"<<endl;
- cout<<"◥1◣"<<endl;
- cout<<"◥2◣"<<endl;
- cout<<"◥3◣"<<endl;
- cout<<"◥4◣"<<endl<<endl;
- system("pause");
- srand(time(NULL));
- while((a!=68)&&(b!=68)&&(c!=68)&&(d!=68))
- {
- r=rand()%4;
- if(r==0)
- a++;
- if(r==1)
- b++;
- if(r==2)
- c++;
- if(r==3)
- d++;
- cout<<"比賽進行中...";
- cout<<endl<<"$-----------------------------------------------------------------||終點||"<<endl;
- for(int i=1;i<=a;i++)
- cout<<" ";
- cout<<"◥1◣"<<endl;
- for(int i=1;i<=b;i++)
- cout<<" ";
- cout<<"◥2◣"<<endl;
- for(int i=1;i<=c;i++)
- cout<<" ";
- cout<<"◥3◣"<<endl;
- for(int i=1;i<=d;i++)
- cout<<" ";
- cout<<"◥4◣"<<endl;
- system("cls");
- }
- cout<<"比賽結束";
- cout<<endl<<"$-----------------------------------------------------------------||終點||"<<endl;
- for(int i=1;i<=a;i++)
- cout<<" ";
- cout<<"◥1◣"<<endl;
- for(int i=1;i<=b;i++)
- cout<<" ";
- cout<<"◥2◣"<<endl;
- for(int i=1;i<=c;i++)
- cout<<" ";
- cout<<"◥3◣"<<endl;
- for(int i=1;i<=d;i++)
- cout<<" ";
- cout<<"◥4◣"<<endl;
- if(a>b && a>c && a>d)
- {
- winner=1;
- }
- else if(a<b && b>c && b>d)
- {
- winner=2;
- }
- else if(a<c && c>b && c>d)
- {
- winner=3;
- }
- else
- {
- winner=4;
- }
- cout<<"比賽結果為 "<<winner<<" 號勝利"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |