本帖最後由 戴安利 於 2018-12-8 17:32 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- 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!=20 && b!=20 && c!=20 && d!=20)
- {
- 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;
- a++;
- for(int i=0;i<=b;i++)
- cout<<" ";
- cout<<"★"<<endl;
- b++;
- for(int i=0;i<=c;i++)
- cout<<" ";
- cout<<"▲"<<endl;
- c++;
- for(int i=0;i<=d;i++)
- cout<<" ";
- cout<<"●"<<endl;
- d++;
- system("cls");
-
- }
- cout<<"賽馬結束..."<<endl;
- cout<<"-------------------------------------------|終點"<<endl;
- for(int i=0;i<=a;i++)
- cout<<" ";
- cout<<"◆"<<endl;
- a++;
- for(int i=0;i<=b;i++)
- cout<<" ";
- cout<<"★"<<endl;
- b++;
- for(int i=0;i<=c;i++)
- cout<<" ";
- cout<<"▲"<<endl;
- c++;
- for(int i=0;i<=d;i++)
- cout<<" ";
- cout<<"●"<<endl;
- d++;
- system("pause");
- return 0;
- }
複製代碼 |