本帖最後由 蔡沛倢 於 2023-7-7 21:01 編輯
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int a[]={0,0,0,0};
- string e[]={"◆","★","▲","●"};
- srand(time(NULL));
- int b=0;
- cout<<"****賽馬場****"<<endl;
- cout<<"-------------------------------------------------------------------------|終點線"<<endl;
- for(int i=0;i<=3;i++)
- {
- cout<<e[i]<<endl;
- }
- system("pause");
- system("cls");
- while(true)
- {
- b=rand()%4;
- a[b]++;
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------|終點線"<<endl;
-
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<=a[i];j++)
- {
- cout<<" ";
- }
- cout<<e[i]<<endl;
- }
- if(a[b]==73)
- {
- break;
- }
- _sleep(50);
- system("cls");
- }
- cout<<"!比賽結束!"<<endl;
- cout<<"-------------------------------------------------------------------------|終點線"<<endl;
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<=a[i];j++)
- {
- cout<<" ";
- }
- cout<<e[i]<<endl;
- }
-
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |