- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- jeb_:
- int a=0,b=0,c=0,d=0,r;
- cout<<"好事成雙賽馬場"<<endl;
- cout<<"--------------------------------------------|終點 "<<endl;
- cout<<"+"<<endl;
- cout<<"◇"<<endl;
- cout<<"≒"<<endl;
- cout<<"★"<<endl;
- system("pause");
- system("cls");
- srand(time(NULL));
- while(a!=42 && b!=42 && c!=42 && d!=42)
- {
- cout<<"賽馬進行中"<<endl;
- cout<<"--------------------------------------------|終點 "<<endl;
- r =rand()%4+1;
- if(r==1)
- a++;
- if(r==2)
- b++;
- if(r==3)
- c++;
- if(r==4)
- d++;
- for(int i=0;i<=a;i++)
- {
- cout<<" ";
- }
- cout<<"+"<<endl;
- for(int i=0;i<=b;i++) //第一匹馬前進
- {
- cout<<" ";
- }
- cout<<"◇"<<endl;
- for(int i=0;i<=c;i++) //第一匹馬前進
- {
- cout<<" ";
- }
- cout<<"≒"<<endl;
- for(int i=0;i<=d;i++) //第一匹馬前進
- {
- cout<<" ";
- }
- cout<<"★"<<endl;
- system ("cls");
-
- }
- cout<<"賽馬結束"<<endl;
- cout<<"--------------------------------------------|終點 "<<endl;
- for(int i=0;i<=a;i++) //第一匹馬最後的位子
- {
- cout<<" ";
- }
- cout<<"+"<<endl;
- for(int i=0;i<=b;i++) //第一匹馬最後的位子
- {
- cout<<" ";
- }
- cout<<"◇"<<endl;
- for(int i=0;i<=c;i++) //第一匹馬最後的位子
- {
- cout<<" ";
- }
- cout<<"≒"<<endl;
- for(int i=0;i<=d;i++) //第一匹馬最後的位子
- {
- cout<<" ";
- }
- cout<<"★"<<endl;
- system("pause");
- system("cls");
- goto jeb_;
- system("pause");
- return 0;
- }
複製代碼 |