本帖最後由 李泳霖 於 2021-10-16 15:40 編輯
使畫面動起來
- #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; //0~3
- 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;
- }
- return 0;
- }
複製代碼 |