標題:
抽籤程式
[打印本頁]
作者:
tonyh
時間:
2014-3-22 16:50
標題:
抽籤程式
本帖最後由 tonyh 於 2014-3-22 16:51 編輯
發揮創意想想看, 抽籤程式在日生活中甚麼時候可以派上用場呢?
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"漢堡","牛排","意麵","炒飯","大便"};
int ball;
srand(time(NULL));
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃甚麼?"<<endl<<endl;
system("pause");
system("cls"); //清畫面
for(int i=0; i<=150; i++)
{
ball=rand()%5; //產生介於 0~4 的隨機亂數
if(i%2==0)
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
else
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
cout<<name[ball]<<endl;
system("cls");
}
cout<<"吃: "<<name[ball]<<"!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2014-3-22 17:03
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[4]={"考試滿分","被車撞","踩到狗屎","撿到鈔票1000元"};
int ball;
srand(time(NULL));
cout<<"*@*抽籤程式*@*"<<endl;
cout<<"今天會遇到什麼事?"<<endl<<endl;
system("pause");
system("cls");
for(int i=0;i<=150;i++)
{
ball=rand()%4;
if(i%2==0)
cout<<"*@*抽籤中*@*"<<endl;
else
cout<<"@*@抽籤中@*@"<<endl;
cout<<name[ball]<<endl;
system("cls");
}
cout<<"今天會"<<name[ball]<<"!!!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2014-3-22 17:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
string name[5]={"Rose 4.5","Rose 4","Lebron II","D HOWARD 5","ADIpure 2"};
int ball;
srand(time(NULL));
cout<<"要買哪雙鞋?"<<endl;
system("pause");
system("cls");
for(int i=0;i<=150;i++)
{
ball=rand()%5;
if(i%2==0)
cout<<"***抽籤中***"<<endl;
else
cout<<"***抽籤中***"<<endl;
cout<<name[ball];
system("cls");
cout<<"買"<<name[ball]<<"!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2014-3-22 17:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"漢堡","牛排","薯條","肉包","泡麵",};
int ball;
srand(time(NULL));
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
cout<<"晚餐\吃啥?"<<endl<<endl;
system("pause");
system("cls");
for(int i=0; i<=150; i++)
{
ball=rand()%5;
if(i%2==0)
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
else
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
cout<<name[ball]<<endl;
system("cls");
}
cout<<"吃:"<<name[ball]<<"!"<<endl<<endl;
system ("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2014-3-22 17:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[]={"被人告白","採到黃金","撿到一千元","被趕出家門","當上總統"};
cout<<"☆★☆ 抽籤程式-神準算命 ☆★☆"<<endl<<endl;
int today;
srand(time(NULL));
system("pause");
for(int i=0; i<=150; i++)
{
today=rand()%5;
if(i%2==0)
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
else
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
cout<<name[today];
system("cls");
}
cout<<"你今天會: "<<name[today]<<"!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2014-3-22 17:13
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"[幸運獎]狗","大象","毒蛇","刺蝟","獅子"};
int ball;
srand(time(NULL));
cout<<"◇◆◇抽籤程式◇◆◇"<<endl;
cout<<"今把天你要哪種動物抱起來?"<<endl;
system("pause");
system("cls");
for(int i=0; i<=150; i++)
{
ball=rand()%5;
if(i%2==0)
cout<<"▁ ▂ ▃ 抽籤中!!"<<endl;
else
cout<<"▅ ▆ ▇ 抽籤中!!"<<endl;
cout<<name[ball]<<endl;
system("cls");
}
cout<<"今天要把"<<name[ball]<<"抱起來"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2014-3-22 17:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[6]={"六福村","九族文化村","劍湖山","溪頭妖怪村","麗寶樂園","義大世界"};
int a;
srand(time(NULL));
cout<<"\/\/\/\/ 抽籤程式 \/\/\/\/"<<endl;
cout<<"明天要去哪裡玩?"<<endl<<endl;
system("pause");
system("cls");
for(int i=0; i<=150; i++)
{
a=rand()%6;
if(i%2==0)
cout<<"//////// 抽籤中 \\\\\\\\"<<endl;
else
cout<<"\\\\\\\\ 抽籤中 ////////"<<endl;
cout<<name[a]<<endl;
system("cls");
}
cout<<"去"<<name[a]<<"!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2014-3-22 17:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[6]={"畫畫","看書","玩電腦","逛街","看電影","看電視"};
int ball;
srand(time(NULL));
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚上要做什麼?"<<endl<<endl;
system("pause");
system("cls");
for(int i=0; i<=150; i++)
{
ball=rand()%6;
if(i%2==0)
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
else
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
cout<<name[ball]<<endl;
system("cls");
}
cout<<"今天晚上要:"<<name[ball]<<"!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2