本帖最後由 tonyh 於 2016-10-15 11:54 編輯
使畫面動起來

 - #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- re:
- system("cls");
- string n[]={"◆","★","▲","●"};
- int s[]={0,0,0,0};
- int r;
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- cout<<n[i]<<endl;
- system("pause");
- while(true)
- {
- cout<<"比賽進行中"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- r=rand()%4; //0~3
- s[r]++;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<n[i]<<endl;
- }
- _sleep(10);
- system("cls");
- if(s[r]==76)
- break;
- }
- cout<<"比賽結果"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- for(int i=0; i<4; i++)
- {
- for(int j=0; j<s[i]; j++)
- cout<<" ";
- cout<<n[i]<<endl;
- }
- system("pause");
- goto re;
- return 0;
- }
複製代碼- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- re:
- system("cls");
- int a=0,b=0,c=0,d=0;
- cout<<"「好事成雙」賽馬場"<<endl;
- cout<<"-------------------------------------------------------------------------| 終點"<<endl;
- cout<<"◆"<<endl;
- cout<<"★"<<endl;
- cout<<"▲"<<endl;
- cout<<"●"<<endl;
- system("pause");
- system("cls");
- while(a!=76 && b!=76 && c!=76 && d!=76)
- {
- int r=rand()%4; //0~3
- if(r==0)
- a++;
- else if(r==1)
- b++;
- else if(r==2)
- c++;
- else
- d++;
- 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;
- _sleep(10);
- 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");
- goto re;
- return 0;
- }
複製代碼 |