本帖最後由 李泳霖 於 2023-12-23 14:10 編輯
加入首頁選單, 新增買入的功能, 執行畫面如下:

在使用者輸入數值後, 畫面更新如下:
 - #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int n=1;
- re:
- system("cls");
- srand(time(NULL));
- int s[]={0,0,0,0};
- string p[]={"◆","★","▲","●"};
- int r=0;
- cout<<"「好事成雙」賽馬場 第"<<n<<"局"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- cout<<p[i]<<endl;
- system("pause");
- system("cls");
- while(s[r]<=73)
- {
- r=rand()%4; //0~3
- s[r]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- _sleep(1);
- system("cls");
- }
- cout<<"比賽結束 由"<<p[r]<<"先馳得點!"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<p[i]<<endl;
- }
- system("pause");
- n++;
- goto re;
- return 0;
- }
複製代碼 |