本帖最後由 呂得銓 於 2023-7-14 17:34 編輯
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int s[]={0,0,0,0};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- while(true)
- {
- system("cls");
- int r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=s[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0; i<=s[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0; i<=s[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0; i<=s[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- if(s[r]==73)
- break;
- _sleep(50);
- }
- system("cls");
- cout<<"比賽結束"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<=s[0]; i++)
- cout<<" ";
- cout<<"◆"<<endl;
- for(int i=0; i<=s[1]; i++)
- cout<<" ";
- cout<<"★"<<endl;
- for(int i=0; i<=s[2]; i++)
- cout<<" ";
- cout<<"▲"<<endl;
- for(int i=0; i<=s[3]; i++)
- cout<<" ";
- cout<<"●"<<endl;
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |