標題:
抽籤程式 (一)
[打印本頁]
作者:
鄭繼威
時間:
2023-6-9 21:05
標題:
抽籤程式 (一)
發揮創意想想看, 抽籤程式在日生活中甚麼時候可以派上用場呢?
(ex. 要吃什麼、誰掃廁所、玩遊戲輸了做什麼處罰...)
抽籤程式流程圖.pdf
抽籤程式.exe
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
srand(time(NULL));
re:
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
//開始抽籤(30次)
for(int i=1; i<=30; i++)
{
//做動畫
if(i%2==1)
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
else
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
cout<<food[rand()%6]<<"!"<<endl; //rand()%6->0~5
_sleep(50); //決定動畫的速度
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
呂得銓
時間:
2023-6-11 18:57
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
srand(time(NULL));
re:
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
for(int i=1; i<=30; i++)
{
if(i%2==1)
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
else
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
cout<<food[rand()%6]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
廖秝瑜
時間:
2023-6-16 20:28
本帖最後由 廖秝瑜 於 2023-6-16 20:38 編輯
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
string food[]={"漢堡","炒飯","牛排","火鍋","義大利麵","鍋燒麵"};
srand(time(NULL));
re:
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"晚餐\吃什麼?"<<endl;
system("pause");
for(int i=1; i<=50; i++)
{
if(i%2==1){
cout<<"★☆★正在抽籤 ★☆★"<<endl;}
else{
cout<<"☆★☆ 正在抽籤 ☆★☆"<<endl;
}
cout<<food[rand()%6]<<endl;
_sleep(85);
system("cls");
cout<<"吃: "<<food[rand()%6]<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
黃子豪
時間:
2023-6-16 20:28
#include<iostream>
#include<ctime>
using namespace std;
int main(){
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
srand(time(NULL));
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl;
for(int i=0; i<=30; i++){
if(i%2==1){
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
}
else{
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
}
cout<<food[rand()%6]<<endl;
_sleep(50);
system("cls");
}
cout<<"吃"<<food[rand()%6]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張絜晰
時間:
2023-6-16 20:30
#include<ctime>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(){
srand(time(NULL));
string f[]={"拉麵","壽司","漢堡","三明治","肉臊飯"};
cout<<"今天吃什麼?"<<endl;
system("pause");
for(int i=1;i<=30;i++){
if(i%2==1){
cout<<"★☆★ 抽籤中 ★☆★"<<endl;}
else{
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;}
cout<<f[rand()%5]<<endl;
_sleep(10);
system("cls");
}
cout<<"今天吃"<<f[rand()%5]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
何權晉
時間:
2023-6-16 20:35
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
string f[]={"sTEAK","bURgER","pAsTA","RaVIOlI","tURD","wATeR","WiLD tOMATO"};
srand(time(NULL));
re:
system("cls");
cout<<"☆★☆Da mEaL rANdOMIZER☆★☆"<<endl;
cout<<"What's the meal of the day?"<<endl<<endl;
system("pause");
for(int i=1;i<=100;i++)
{
if(i%2==0){
cout<<"☆★☆Processing...☆★☆"<<endl;
}
else{
cout<<"★☆★Processing...★☆★"<<endl;
}
cout<<f[rand()%7]<<"!"<<endl;
_sleep(100);
system("cls");
}
cout<<"Meal of the day: "<<f[rand()%7]<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
呂宗晉
時間:
2023-6-16 20:38
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
srand(time(NULL));
re:
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
for(int i=1; i<=30; i++)
{
if(i%2==1)
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
else
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
cout<<food[rand()%6]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
蔡沛倢
時間:
2023-6-16 20:42
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
string lose[]={"仰臥起坐","跑操場","開合跳","平板支撐","伏地挺身","蛙跳"};
srand(time(NULL));
re:
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"輸的懲罰是什麼?"<<endl<<endl;
system("pause");
for(int a=1;a<=20;a++)
{
if(a%2==1)
{
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
}
else
{
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
}
cout<<lose[rand()%6]<<endl<<endl;
_sleep(250);
system("cls");
}
cout<<"罰:"<<lose[rand()%6]<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃品禎
時間:
2023-7-1 17:11
#include<cstdlib>
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl;
system("pause");
for (int i=0;i<=100;i++)
{
if(i%2==0)
{
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
}
else if(i%2==1)
{
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
}
cout<<"吃"<<food[rand()%5] <<endl;
_sleep(100);
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
吳柏潁
時間:
2023-8-3 17:08
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
srand(time(NULL));
re:
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
for(int a=0;a<30;a++){
if(a%2==1)
cout<<"★☆★抽籤中★☆★"<<endl;
else
cout<<"☆★☆抽籤中☆★☆"<<endl;
cout<<food[rand()%6];
_sleep(500);
system("cls");
}
cout<<food[rand()%6]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
邱品惟
時間:
2023-8-8 21:20
#include<iostream>
#include<ctime>
using namespace std;
int main()
{
string food[]={"漢堡","牛排","羊肉爐","意麵","大便","餿水"};
srand(time(NULL));
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
for(int i=1; i<=15; i++)
{
cout<<"★☆★ 抽籤中 ★☆★"<<endl;
cout<<food[rand()%6]<<"!"<<endl;
_sleep(50);
system("cls");
cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
cout<<food[rand()%6]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
朱奕祈
時間:
2024-2-19 20:51
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
string food[]={"漢堡","牛排","羊肉爐","意麵","起司泡麵","鴨肉湯"};
system("cls");
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
for(int i=1;i<=30;i++)
{
if(i%2==1)
cout<<"★☆★抽籤中★☆★"<<endl;
else
cout<<"☆★☆抽籤中☆★☆"<<endl;
cout<<food[rand()%6]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吃"<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2