- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- 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!=69 && b!=69 && c!=69&& d!=69)
- {
- 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 re;
- system("pause");
- return 0;
- }
複製代碼 |