標題:
抽籤程式 (一)
[打印本頁]
作者:
鄭繼威
時間:
2022-12-28 19:30
標題:
抽籤程式 (一)
本帖最後由 鄭繼威 於 2023-1-4 19:27 編輯
發揮創意想想看, 抽籤程式在日生活中甚麼時候可以派上用場呢?
(ex. 要吃什麼、誰掃廁所、玩遊戲輸了做什麼處罰...)
[attach]14796[/attach]
抽籤程式.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;
_sleep(50); //決定動畫的速度
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
林劭澧
時間:
2022-12-28 20:42
#include<iostream>
#include<cstdlib>
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;
_sleep(50); //決定動畫的速度
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
李彣
時間:
2022-12-28 20:43
#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;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
林劭杰
時間:
2022-12-28 20:44
#include<iostream>
#include<cstdlib>
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(5);
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
黃裕恩
時間:
2022-12-28 20:44
#include<iostream>
#include<cstdlib>
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(100);
system("cls");
}
cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2