標題:
抽籤程式 (二)
[打印本頁]
作者:
王瑞喻
時間:
2019-11-21 20:45
標題:
抽籤程式 (二)
本帖最後由 王瑞喻 於 2019-11-30 10:23 編輯
改寫抽籤程式(一),在抽籤過程中加上閃爍效果
本帖隱藏的內容需要回復才可以瀏覽
作者:
洪榜蔓
時間:
2019-11-23 11:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string food[]={"牛排","義大利麵","火鍋","生菜沙拉","焗烤","不吃"};
srand(time(NULL));
re:
system("cls");
cout<<" 抽籤程式 "<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
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;
}
複製代碼
作者:
陳宇柏
時間:
2019-11-23 11:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int eat;
string food[4]={"牛排","珍奶","臭豆腐","炒飯"};
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl;
system("pause");
srand(time(NULL));
eat=rand()%4;
for(int i=1; i<=30; i++)
{
if(i%2==1)
cout<<"☆★☆抽籤中☆★☆"<<endl;
else
cout<<"★☆★抽籤中★☆★"<<endl;
cout<<food[rand()%4]<<endl;
_sleep(50);
system("cls");
}
cout<<"吃"<<food[eat]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
曾宥程
時間:
2019-11-23 11:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
cout<<"★☆★抽籤程式★☆★"<<endl<<endl;
cout<<"今天吃啥?"<<endl<<endl;
string food[5]={"吃牛排","吃陽春麵","吃雞排","吃芝麻球","...等等,你那麼胖,還吃得下?!"};
system("pause");
for(int i=1; i<=30; i++)
{
if(i%2==1)
{
cout<<"★☆★抽籤程式★☆★"<<endl;
}else
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<food[rand()%5]<<endl;
_sleep(50);
system("cls");
}
cout<<"今天"<<food[rand()%5]<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡少宇
時間:
2019-11-23 11:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
string food[8]={"蔥油餅","牛排","義大利麵","炒飯","便當","日本壽司","頓飯","油飯"};
cout<<"◇◆◇抽籤程式◇◆◇"<<endl;
cout<<"今天晚餐\吃:"<<food[rand()%5];
system("pause");
for(int i=1; i<=30; i++)
{
if(i%2==1)
cout<<"◇◆◇抽籤中◇◆◇"<<endl;
else
cout<<"◆◇◆抽籤中◆◇◆"<<endl;
cout<<food[rand()%5]<<"!"<<endl;
_sleep;
system("cls");
}
system("pause");
return 0;
}
複製代碼
作者:
黃傳耀
時間:
2019-11-23 11:22
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int main()
{
re:
int count=0,big=0,small=0,number=0,again=0,flag=0;
srand(time(NULL));
cout<<"請輸入最高幾號:";
cin>>big;
if(big<=0)
{
flag = 1;
goto re3;
}
cout<<"請輸入最低幾號:";
cin>>small;
if(small<=0||big<small)
{
flag = 1;
goto re3;
}
cout<<"請輸入抽幾個人:";
cin>>count;
if(count<=0)
{
flag = 1;
goto re3;
}
re3:
if(flag==0)
{
cout<<"抽籤中";
for(int j=1;j<=5;j++)
{
cout<<rand()%(big-small+1)+small;
_sleep(100);
system("cls");
}
for(int i=1;i<=count;i++)
{
number = rand()%(big-small+1)+small;
cout<<"第"<<i<<"個號碼是:"<<number<<endl;
}
re2:
cout<<"還要抽嗎?(1)要(2)不要:";
cin>>again;
if(again==1)
goto re;
else if(again != 2)
{
cout<<"輸入錯誤!";
goto re2;
}
}
else
{
cout<<"你輸入錯誤了"<<endl;
goto re;
}
system("pause");
return 0;
}
複製代碼
作者:
郭哲維
時間:
2019-11-23 11:27
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int dinner;
cout<<"***抽籤程式***"<<endl;
cout<<"今天晚餐\吃甚麼?"<<endl;
string name[3]={"牛排","咖哩飯","義大利麵"};
system("pause");
for(int i=1; i<=30;i++)
{
if(i%2==1)
cout<<"*%*抽籤中*%*"<<endl;
else
cout<<"%*%抽籤中%*%"<<endl;
cout<<name[rand()%3]<<"!"<<endl;
_sleep(50);
system("cls");
}
dinner=rand()%3+1;
cout<<"吃: "<<name[dinner-1]<<"!"<<endl;
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
鄭羽捷
時間:
2019-11-23 11:28
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
string food[8]={"牛排","義大利麵","印度甩餅","日本壽司","便當","油飯","炒飯","臭豆腐"};
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()%8]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吃:"<<food[rand()%8]<<"!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林孟蓁
時間:
2019-11-23 11:33
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
string name[5]={"長笛","豎笛","雙簧管","法國號","巴松管"};
cout<<"★☆★抽籤程式★☆★"<<endl;
cout<<"今天要吹甚麼樂器?"<<endl<<endl;
system("pause");
for(int i=1;i<=30;i++)
{
if(i%2==1)
cout<<"★☆★抽籤程式★☆★"<<endl;
else
cout<<"☆★☆抽籤中☆★☆"<<endl;
cout<<"吹: "<<name[rand()%5]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<name[rand()%5]<<"!"<<endl;
cout<<endl<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王翎璇
時間:
2019-11-23 11:37
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
string name[5]={"長笛","豎笛","雙簧管","法國號","小喇叭"};
cout<<"☆★☆抽籤程式☆★☆"<<endl;
cout<<"今天要吹甚麼樂器?"<<endl;
cout<<endl<<endl;
system("pause");
for(int i=1;i<=30;i++)
{
if(i%2==1)
cout<<"☆★☆抽籤中☆★☆"<<endl;
else
cout<<"★☆★抽籤中★☆★"<<endl;
cout<<"吹: "<<name[rand()%5]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吹: "<<name[rand()%5]<<"!"<<endl;
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王建葦
時間:
2019-11-30 09:43
本帖最後由 王建葦 於 2019-11-30 09:45 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
int i;
string c[]= {"蔡英文(民主進步黨)",
"韓國瑜(中國國民黨)",
"宋楚瑜(親民黨)",
"賴清德(民主進步黨)",
"張善政(無黨籍)",
"余湘(無黨籍)"};
cout<<"----抽籤程式-----"<<endl;
cout<<"本次總統大選候選人(第15屆):"<<endl;
for(i=0;i<6;i++)
{
cout<<c[i]<<endl;
}
cout<<"共"<<i<<"位"<<endl;
cout<<"--------------------------------------------------"<<endl;
cout<<"預測結果:"<<endl<<endl;
system("pause");
for(int r=1;r<=rand();r++)
{
if(r%2==1)
{
cout<<"------預測結果:------"<<endl<<endl;
cout<<"當選人:"<<c[rand()%5]<<endl;
}else
{
cout<<"++++++預測結果:++++++"<<endl<<endl;
cout<<"當選人:"<<c[rand()%5]<<endl;
}
_sleep(50);
system("cls");
}
cout<<"當選人:"<<c[rand()%5]<<endl;
cout<<"--------------------------------------------------"<<endl;
cout<<"提醒您:2020/1/11日記得前往戶籍地之投票所投票並記得攜帶:身分證(必備)、印章、投票通知"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪藜芸
時間:
2019-11-30 10:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string f[]={"漢堡","牛排","羊肉爐","意麵","便當"};
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<<f[rand()%5]<<"!"<<endl;
_sleep(50);
system("cls");
}
cout<<"吃 "<<f[rand()%5]<<"!"<<endl<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
洪子涵
時間:
2019-12-14 11:39
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"乞丐","毛毛蟲","狗","貓","豬"};
srand(time(NULL));
cout<<"☆★☆大家來抽籤 ☆★☆" <<endl<<"你前世是什麼?"<<endl;
system("pause");
system("cls");
for(int i=0;i<=50;i++)
{
if(i%2==0)
cout<<"☆★☆抽籤中 ☆★☆"<<endl;
else
cout<<"★☆★抽籤中 ★☆★"<<endl;
cout<<name[rand()%5];
if(i<25)
_sleep(40);
else
_sleep(40+(i-24)*(i-24));
system("cls");
}
cout<<"是 : "<<name[rand()%5]<<"!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
駱顗安
時間:
2020-8-20 20:24
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
srand(time(NULL));
string m[]={"炒飯",
"烏龍麵",
"牛排",
"火鍋",
"燒烤"},
n[]={"☆★☆ 抽籤中 ☆★☆",
"★☆★ 抽籤中 ★☆★"};
cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
cout<<"今天晚餐\吃什麼?"<<endl<<endl;
system("pause");
for(int i=1;i<=20;i++)
{
system("cls");
cout<<n[i%2]<<endl;
cout<<m[rand()%5]<<"!"<<endl;
_sleep(50);
}
system("cls");
cout<<"吃: "<<m[rand()%5]<<"!"<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2