返回列表 發帖
本帖最後由 余柏緯 於 2021-1-30 19:53 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.         string food[]={"焗烤","牛排","滷肉飯","粥","漢堡","炸雞"};
  8.         srand(time(NULL));
  9.         re:
  10.         system("cls");
  11.         cout<<"□■□抽籤程式 □■□"<<endl;
  12.         cout<<"今天晚餐\吃什麼?"<<endl;
  13.         system("pause");
  14.     for(int i=1; i<=52; i++)
  15.     {
  16.         if(i%2==1)
  17.             cout<<"□■□ 抽籤中 □■□"<<endl;
  18.         else
  19.             cout<<"■□■ 抽籤中 ■□■"<<endl;
  20.         cout<<food[rand()%6]<<"!"<<endl;
  21.         if(i<=30)
  22.             _sleep(20);
  23.         else
  24.             _sleep(20+(i-30)*(i-30);
  25.         system("cls");   
  26.     }
  27.         cout<<"吃: "<<food[rand()%6]<<"!"<<endl<<endl;
  28.     system("pause");
  29.     goto re;   
  30.     return 0;
  31. }
複製代碼

TOP

返回列表