本帖最後由 李泳霖 於 2022-6-17 19:39 編輯
使畫面動起來
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- srand(time(NULL));
- int s[4]={0,0,0,0};
- string p[4]={"◆","★","▲","●"};
- int r=0;
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0;i<=3;i++)
- cout<<p[i]<<endl;
-
- system("pause");
- system("cls");
- while(s[r]<=73)
- {
- 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(10);
- system("cls");
- }
- cout<<"比賽結束"<<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");
- goto re;
- return 0;
- }
複製代碼 |