本帖最後由 章幼莛 於 2019-4-20 14:42 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- int a=0,b=0,c=0,d=0,h;
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"|--------------------------------------------------|"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- system("cls");
- srand(time(NULL));
-
- while(a!=50 && b!=50 && c!=50 && d!=50)
- {
- cout<<"賽馬進行中"<<endl;
- cout<<"|--------------------------------------------------|"<<endl;
- h = rand()%4+1;
- if(h==1)
- a++;
- if(h==2)
- b++;
- if(h==3)
- c++;
- if(h==4)
- d++;
-
- for(int i=0;i<=a;i++)
- {
- cout<<" ";
- }
- cout<<"◆"<<endl;
- for(int i=0;i<=b;i++)
- {
- cout<<" ";
- }
- cout<<"★"<<endl;
- for(int i=0;i<=c;i++)
- {
- cout<<" ";
- }
- cout<<"▲"<<endl;
- for(int i=0;i<=d;i++)
- {
- cout<<" ";
- }
- cout<<"●"<<endl;
- system("cls");
- }
- cout<<"比賽結束"<<endl;
- cout<<"|--------------------------------------------------|"<<endl;
- for(int i=0;i<=a;i++)
- {
- cout<<" ";
- }
- cout<<"◆"<<endl;
- for(int i=0;i<=b;i++)
- {
- cout<<" ";
- }
- cout<<"★"<<endl;
- for(int i=0;i<=c;i++)
- {
- cout<<" ";
- }
- cout<<"▲"<<endl;
- for(int i=0;i<=d;i++)
- {
- cout<<" ";
- }
- cout<<"●"<<endl;
- system("pause");
- system("cls");
- goto re;
-
- system("pause");
- return 0;
- }
複製代碼 |