返回列表 發帖
本帖最後由 章幼莛 於 2019-3-30 14:27 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a;
  7.     cout<<"☆★☆抽籤程式☆★☆"<<endl;
  8.     cout<<"今晚吃什麼?"<<endl;
  9.     string food[5]={"炒飯","炒麵","意麵","煎餃","滷味"};
  10.     system("pause");
  11.     system("cls");
  12.     srand(time(NULL));
  13.     for(int i=1;i<=100;i++)
  14.     {
  15.             a=rand()%5;
  16.             if(i%2==0)
  17.             {
  18.                  cout<<"☆★☆抽籤中☆★☆"<<endl;
  19.             }else
  20.             {
  21.                  cout<<"★☆★抽籤中★☆★"<<endl;
  22.             }
  23.             cout<<food[a]<<endl;
  24.             system("cls");
  25.     }
  26.     cout<<"今天晚上選的食物是:"<<food[a]<<endl;
  27.     system("pause");
  28.     return 0;   
  29. }
複製代碼

TOP

返回列表