- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int round=1;
- re:
- system("cls");
- int s[]={0,0,0,0};
- string p[]={"◆", "★", "▲", "●"};
- int win;
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場 第"<<round<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- cout<<p[i]<<endl;
- }
- system("pause");
-
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
-
- for(int j=0; j<4; j++){
- for(int i=0; i<=s[j]; i++){
- cout<<" ";
- }
- cout<<p[j]<<endl;
- }
-
- if(s[r]==73){
- win=r;
- break;
- }
-
- _sleep(5);
- }
- cout<<"比賽結束! 由 "<<p[win]<<" 先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
-
- for(int j=0; j<4; j++){
- for(int i=0; i<=s[j]; i++){
- cout<<" ";
- }
- cout<<p[j]<<endl;
- }
-
- system("pause");
- round++;
- goto re;
- return 0;
- }
複製代碼 |