本帖最後由 吳孟樵 於 2025-2-1 11:53 編輯
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int r=0,n=1,speed=50;
- re:
- system("cls");
- int s[4]= {0,0,0,0};
- srand(time(NULL));
- cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
- cout<<"------------------------------------------------------|終點"<<endl;
- string p[4]= {"◆","★","▲","●"};
- for(int i=0; i<=3; i++)
- {
- cout<<p[i]<<endl;
- }
- system("pause");
- system("cls");
- while(s[r]<=52)
- {
- r=rand()%4;
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"------------------------------------------------------|終點"<<endl;
- for(int i=0; i<=3; i++)
- {
- for(int j=0; j<=s[i]; j++)
- {
- cout<<" ";
- }
- cout<<p[i]<<endl;
- }
- _sleep(speed);
- system("cls");
- }
- cout<<"比賽結束! 由"<<p[r]<<"先馳得點!"<<endl;
- cout<<"------------------------------------------------------|終點"<<endl;
- for(int i=0; i<=3; i++)
- {
- for(int j=0; j<=s[i]; j++)
- {
- cout<<" ";
- }
- cout<<p[i]<<endl;
- }
- system("pause");
- n++;
- goto re;
- return 0;
- }
複製代碼 |