- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string winner;
- int a=0 ,b=0, c=0, d=0,r;
- cout<<"$ 老師同學賽馬場(賭老師的必輸光用看的就知道) $"<<endl;
- cout<<"-----------------------------------------------------------------|終點"<<endl;
- cout<<"~老師"<<endl;
- cout<<"~~~~~逸群"<<endl;
- cout<<"~~~~以諾"<<endl;
- cout<<"~~~凱言"<<endl;
- srand(time(NULL));
- system("pause");
- while((a!=60)&&(b!=60)&&(c!=60)&&(d!=60))
- {
- r=rand()%4;
- if(r==0)
- a++;
- else if(r==1)
- b++;
- else if(r==2)
- c++;
- else
- d++;
- cout<<"比賽進行中....";
- cout<<endl<<"-----------------------------------------------------------|終點"<<endl;
- for(int i=1;i<=a;i++)
- cout<<" ";
- cout<<"~老師"<<endl;
- for(int i=1;i<=b;i++)
- cout<<" ";
- cout<<"~~~~~逸群"<<endl;
- for(int i=1;i<=c;i++)
- cout<<" ";
- cout<<"~~~~以諾"<<endl;
- for(int i=1;i<=d;i++)
- cout<<" ";
- cout<<"~~~凱言"<<endl;
- system("cls");
- if(a>b && a>c && a>d)
- winner="老師";
- else if(b>a && b>c && b>d)
- winner="逸群";
- else if(c>a && c>b && c>d)
- winner="以諾";
- else
- winner="凱言"; }
- cout<<"比賽結束! 由 "<<winner<<" 選手先馳得點!"<<endl;
- cout<<endl<<"-----------------------------------------------------------|終點"<<endl;
- for(int i=1;i<=a;i++)
- cout<<" ";
- cout<<"~老師"<<endl;
- for(int i=1;i<=b;i++)
- cout<<" ";
- cout<<"~~~~~逸群"<<endl;
- for(int i=1;i<=c;i++)
- cout<<" ";
- cout<<"~~~~以諾"<<endl;
- for(int i=1;i<=d;i++)
- cout<<" ";
- cout<<"~~~凱言"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |