標題:
賽馬程式 (二)
[打印本頁]
作者:
陳品肇
時間:
2019-4-20 12:42
標題:
賽馬程式 (二)
本帖最後由 陳品肇 於 2019-4-20 14:37 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r; //r 我隨機挑到馬匹
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls"); //清空畫面
srand(time(NULL)); //撒亂樹種子
while(a!=70 && b!=70 && c!=70&& d!=70) //判斷四隻馬只要有一隻到終點就跳離while
{
cout<<"賽馬進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1; //產生1~4亂數 隨機挑馬1~4其中一隻
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==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;
}
複製代碼
作者:
章幼莛
時間:
2019-4-20 14:26
本帖最後由 章幼莛 於 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;
}
複製代碼
作者:
吳孟修
時間:
2019-4-20 14:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r;
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && d!=70)
{
cout<<"賽馬進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4+1;
if(r==1)
{
a++;
}
if(r==2)
{
b++;
}
if(r==3)
{
c++;
}
if(r==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;
}
複製代碼
作者:
蘇昱全
時間:
2019-4-20 14:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r;
cout<<"㊣$賽馬場$㊣"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70&&b!=70&&c!=70&&d!=70 )
{
cout<<"賽馬進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==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;
}
複製代碼
作者:
洪寬瀧
時間:
2019-4-20 14:46
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
jeb_:
int a=0,b=0,c=0,d=0,r;
cout<<"好事成雙賽馬場"<<endl;
cout<<"--------------------------------------------|終點 "<<endl;
cout<<"+"<<endl;
cout<<"◇"<<endl;
cout<<"≒"<<endl;
cout<<"★"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=42 && b!=42 && c!=42 && d!=42)
{
cout<<"賽馬進行中"<<endl;
cout<<"--------------------------------------------|終點 "<<endl;
r =rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==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 jeb_;
system("pause");
return 0;
}
複製代碼
作者:
湯郡一
時間:
2019-4-20 14:46
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r;
cout<<"「好事成雙」賽馬場"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70&& d!=70)
{
cout<<"賽馬進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==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;
}
複製代碼
作者:
田宇任
時間:
2019-4-20 14:46
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r;
cout<<"賽馬場"<<endl;
cout<<"--------------------------------------------------------------------|終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && d!=70)
{
cout<<"起跑嘍~~~~~"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r = rand()%4+1;
if(r==1)
a++;
if(r==2)
b++;
if(r==3)
c++;
if(r==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;
}
複製代碼
作者:
王瑞喻
時間:
2019-4-20 14:48
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r;
cout<<"賽~馬~"<<endl;
cout<<"|起點|--------------------------------------------------------------|終點|"<<endl;
cout<<"★"<<endl;
cout<<"㊣"<<endl;
cout<<"▽"<<endl;
cout<<"◆"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && d!=70)
{
cout<<"~賽馬進行中~"<<endl;
cout<<"|起點|--------------------------------------------------------------|終點|"<<endl;
r=rand()%4;
if(r==0)
{
a++;
}
if(r==1)
{
b++;
}
if(r==2)
{
c++;
}
if(r==3)
{
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;
}
複製代碼
作者:
吳孟書
時間:
2019-4-20 14:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int a=0,b=0,c=0,d=0,r;
cout<<"好事成雙賽馬場"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
system("pause");
system("cls");
srand(time(NULL));
while(a!=70 && b!=70 && c!=70 && d!=70)
{
cout<<"比賽進行中"<<endl;
cout<<"------------------------------------------------------------------------| 終點"<<endl;
r=rand()%4+1;
if(r==1)
{
a++;
}
if(r==2)
{
b++;
}
if(r==3)
{
c++;
}
if(r==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;
}
複製代碼
作者:
曲書辰
時間:
2019-4-27 13:17
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
int b[4]={0,0,0,0};
cout<<"好事成雙 賽馬場"<<endl;
cout<<"--------------------------------------"<<endl;
cout<<"*"<<endl;
cout<<"+"<<endl;
cout<<"0"<<endl;
cout<<"?"<<endl;
system("pause");
while(true)
{
srand(time(NULL));
a==rand();
b[a]++;
cout<<"好事成雙 進行中"<<endl;
cout<<"--------------------------------------"<<endl;
for(int i=0;i<=b{0};i++)
{cout<<" ";
}
cout<<"*"<<endl;
for(int i=0;i<=b{1};i++)
{cout<<" ";
}
cout<<"+"<<endl;
for(int i=0;i<=b{2};i++)
{cout<<" ";
}
cout<<"0"<<endl;
for(int i=0;i<=b{3};i++)
{cout<<" ";
}
cout<<"?"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2