標題:
抽籤程式
[打印本頁]
作者:
陳品肇
時間:
2019-3-30 13:16
標題:
抽籤程式
本帖最後由 陳品肇 於 2019-3-30 14:14 編輯
發揮創意想想看, 抽籤程式在日生活中甚麼時候可以派上用場呢?
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n ;
string name[5]={"雞排","便當","麵","粥","火鍋"};
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今晚你要吃什麼?"<<endl;
system("pause"); //畫面停留
system("cls"); //畫面清空
srand(time(NULL));
for(int i=1;i<=100;i++) //做出跑馬燈的效果
{
//產生0~4
n = rand()%5;
if(i%2==0)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}else
{
cout<<"★☆★抽籤中★☆★"<<endl;
}
cout<<name[n]<<endl; //印出食物名稱
system("cls"); //畫面清空
}
cout<<"今晚選重的食物是:"<<name[n]<<endl; //印出食物名稱
system("pause");
return 0;
}
複製代碼
作者:
吳孟修
時間:
2019-3-30 14:24
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x;
string n[]={"飯","麵","粥","漢堡","火鍋"};
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今晚你要吃什麼?\n"<<endl;
system("pause");
system("cls");
srand(time(NULL));
for(int i=1;i<=150;i++)
{
x=rand()%5;
if(i%2==0)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}
else
{
cout<<"★☆★抽籤中★☆★"<<endl;
}
cout<<n[x]<<endl;
system("cls");
}
cout<<"今晚選中的食物是:"<<n[x]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
章幼莛
時間:
2019-3-30 14:24
本帖最後由 章幼莛 於 2019-3-30 14:27 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a;
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今晚吃什麼?"<<endl;
string food[5]={"炒飯","炒麵","意麵","煎餃","滷味"};
system("pause");
system("cls");
srand(time(NULL));
for(int i=1;i<=100;i++)
{
a=rand()%5;
if(i%2==0)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}else
{
cout<<"★☆★抽籤中★☆★"<<endl;
}
cout<<food[a]<<endl;
system("cls");
}
cout<<"今天晚上選的食物是:"<<food[a]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
田宇任
時間:
2019-3-30 14:25
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n;
string name[5]={"香蕉","鳳梨","西瓜","蘋果","蓮霧"};
cout<<"★☆★抽籤程式★☆★"<<endl;
cout<<"吃什麼水果?"<<endl;
system("pause");
system("cls");
srand(time(NULL));
for(int i=1;i<=120;i++)
{
n = rand()%5;
if(i%2==0)
{
cout<<"☆★☆為您決定中...☆★☆"<<endl;
}else
{
cout<<"★☆★為您決定中...★☆★"<<endl;
}
cout<<name[n]<<endl;
system("cls");
}
cout<<"吃:"<<name[n]<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
吳孟書
時間:
2019-3-30 14:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n;
string d[5]={"飯","麵","粥","漢堡","火鍋"};
srand(time(NULL));
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今晚要吃什麼?(按Enter鍵開始抽籤)"<<endl;
system("pause");
system("cls");
for(int i=0;i<=150;i++)
{
n=rand()%5;
if(i%2==0)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}
else
{
cout<<"★☆★抽籤中★☆★"<<endl;
}
cout<<d[n]<<endl;
system("cls");
}
cout<<"今晚吃"<<d[n]<<"!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
曲書辰
時間:
2019-3-30 14:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n;
string f[]={"湯","飯","肉","麵","菜","水果"};
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今晚你要吃什麼"<<endl;
system("cls");
srand(time(NULL));
for(int i=1;i<200;i++)
{
n=rand()%5;
if(i%2==0)
cout<<"☆★☆抽籤程式☆★☆"<<endl;
else
cout<<"★☆★抽籤中★☆★"<<endl;
cout<<f[n]<<endl;
system("cls");
}
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<f[n]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪寬瀧
時間:
2019-3-30 14:34
#include<iostream> //☆★◇◆□■▽▼㊣℅¯>﹤㏒
#include<cstdlib>
using namespace std;
int main()
{
int h;
string name[5]={"咖哩飯","煎餃","牛肉麵","炒飯","水餃"};
cout<<"∴抽籤程式∴"<<endl;
cout<<"≒今晚吃甚麼≒"<<endl;
system("pause");
system("cls");
srand(time(NULL));
for(int i=1;i<=300;i++)
{
h=rand()%5;
if(i%2==0)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}else
{
cout<<"★☆★抽籤中★☆★"<<endl;
}
cout<<name[h]<<endl;
system("cls");
}
cout<<"今晚選中的食物是:"<<name[h]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王瑞喻
時間:
2019-3-30 14:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n;
string name[5]={"白色","紅色","黃色","綠色","紫色"};
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今天穿甚麼顏色?"<<endl;
system("pause");//畫面暫停
system("cls"); //畫面清空
srand(time(NULL));
for(int i=1;i<=100;i++)
{
n=rand()%5;
if(i%2==0)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}else
{
cout<<"★☆★抽籤中★☆★"<<endl;
}
cout<<name[n]<<endl;
system("cls");
}
cout<<"今天要穿的顏色是:"<<name[n]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蘇昱全
時間:
2019-4-6 11:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n[5]={"齊爾","甲蟲","悟空","兔子","瑟斐斯"};
srand(time(NULL));
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今天你要玩什麼角色?"<<endl;
system("pause");
system("cls");
for(int i=1;i<=50;i++)
{
if(i%2==1)
{
cout<<"☆★☆抽籤中☆★☆"<<endl;
}else
{
cout<<"★☆★抽籤中★☆★"<<endl;
cout<<"是:"<<n[rand()%5]<<endl;
}
if(i<30)
_sleep(50);
else
_sleep(50+(i-30)*(i-30));
system("cls");
}
cout<<"選中的角色是:"<<n[rand()%5]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
湯郡一
時間:
2019-4-6 11:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n[]={"漢堡","三明治","炒飯","吐司夾蛋","披薩"};
srand(time(NULL));
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今天中午要吃什麼?"<<endl;
system("pause");
system("cls");
for(int i=1;i<=50;i++)
{
if(i%2==1)
cout<<"☆★☆抽籤中☆★☆"<<endl;
else
cout<<"☆★☆抽籤中☆★☆"<<endl;
cout<<"吃"<<n[rand()%5]<<endl;
if(i<30)
_sleep(20);
else
_sleep(20+(i-30)*(i-30));
system("cls");
}
cout<<"吃:"<<n[rand()%5]<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2