本帖最後由 李知易 於 2015-8-29 11:07 編輯
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int a=0,b=0,c=0,d=0,r;
- srand(time(NULL));
- cout<<"[馬到成功\] 賽馬場"<<endl;
- cout<<"--------------------------------------------------------------------------|終點"<<endl;
- cout<<"#1"<<endl;
- cout<<"#2"<<endl;
- cout<<"#3"<<endl;
- cout<<"#4"<<endl;
- cout<<endl;
- cout<<"#1: 閃電"<<endl;
- cout<<"#2: 傑哥"<<endl;
- cout<<"#3: 內褲哥"<<endl;
- cout<<"#4: 辣椒妹"<<endl;
- cout<<endl;
- system("pause");
- system("cls");
-
- while(a<=35 && c<=35 && b<=35 && d<=35)
- {
- r=rand()%4+1;
- if(r==1)
- a++;
- else if(r==2)
- b++;
- else if(r==3)
- c++;
- else
- d++;
- cout<<"比賽進行中"<<endl;
- cout<<"--------------------------------------------------------------------------|終點"<<endl;
- for(int i=0;i<=a;i++)
- cout<<" ";
- cout<<"#1"<<endl;
- for(int i=0;i<=b;i++)
- cout<<" ";
- cout<<"#2"<<endl;
- for(int i=0;i<=c;i++)
- cout<<" ";
- cout<<"#3"<<endl;
- for(int i=0;i<=d;i++)
- cout<<" ";
- cout<<"#4"<<endl;
-
- system("cls");
- }
- cout<<"比賽結束"<<endl;
- cout<<"--------------------------------------------------------------------------|終點"<<endl;
- for(int i=0;i<=a;i++)
- cout<<" ";
- cout<<"#1"<<endl;
- for(int i=0;i<=b;i++)
- cout<<" ";
- cout<<"#2"<<endl;
- for(int i=0;i<=c;i++)
- cout<<" ";
- cout<<"#3"<<endl;
- for(int i=0;i<=d;i++)
- cout<<" ";
- cout<<"#4"<<endl;
-
- cout<<endl;
- cout<<"#1: 閃電"<<endl;
- cout<<"#2: 傑哥"<<endl;
- cout<<"#3: 內褲哥"<<endl;
- cout<<"#4: 辣椒妹"<<endl;
- cout<<endl;
-
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |