返回列表 發帖

抽籤程式

本帖最後由 tonyh 於 2014-3-22 16:51 編輯

發揮創意想想看, 抽籤程式在日生活中甚麼時候可以派上用場呢?
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"漢堡","牛排","意麵","炒飯","大便"};
  7.     int ball;
  8.     srand(time(NULL));
  9.     cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
  10.     cout<<"今天晚餐\吃甚麼?"<<endl<<endl;
  11.     system("pause");
  12.     system("cls");       //清畫面
  13.     for(int i=0; i<=150; i++)
  14.     {
  15.         ball=rand()%5;  //產生介於 0~4 的隨機亂數
  16.         if(i%2==0)
  17.             cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
  18.         else
  19.             cout<<"★☆★ 抽籤中 ★☆★"<<endl;
  20.         cout<<name[ball]<<endl;
  21.         system("cls");
  22.     }
  23.     cout<<"吃: "<<name[ball]<<"!"<<endl<<endl;
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[4]={"考試滿分","被車撞","踩到狗屎","撿到鈔票1000元"};
  7.     int ball;
  8.     srand(time(NULL));
  9.     cout<<"*@*抽籤程式*@*"<<endl;
  10.     cout<<"今天會遇到什麼事?"<<endl<<endl;
  11.     system("pause");
  12.     system("cls");
  13.     for(int i=0;i<=150;i++)
  14.     {
  15.         ball=rand()%4;
  16.         if(i%2==0)
  17.             cout<<"*@*抽籤中*@*"<<endl;
  18.         else
  19.             cout<<"@*@抽籤中@*@"<<endl;   
  20.         cout<<name[ball]<<endl;
  21.         system("cls");
  22.     }
  23.     cout<<"今天會"<<name[ball]<<"!!!"<<endl<<endl;     
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main ()
  5. {
  6. string name[5]={"Rose 4.5","Rose 4","Lebron II","D HOWARD 5","ADIpure 2"};
  7. int ball;   
  8. srand(time(NULL));
  9. cout<<"要買哪雙鞋?"<<endl;
  10. system("pause");
  11. system("cls");
  12. for(int i=0;i<=150;i++)
  13. {
  14. ball=rand()%5;        
  15.    if(i%2==0)      
  16.     cout<<"***抽籤中***"<<endl;
  17.     else   
  18.     cout<<"***抽籤中***"<<endl;
  19.     cout<<name[ball];
  20.     system("cls");
  21.     cout<<"買"<<name[ball]<<"!"<<endl;   
  22. }   
  23. system("pause");   
  24. return 0;   
  25. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"漢堡","牛排","薯條","肉包","泡麵",};
  7.     int ball;
  8.     srand(time(NULL));
  9.     cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
  10.     cout<<"晚餐\吃啥?"<<endl<<endl;  
  11.     system("pause");
  12.     system("cls");
  13.     for(int i=0; i<=150; i++)
  14.     {
  15.         ball=rand()%5;
  16.         if(i%2==0)
  17.             cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
  18.         else
  19.             cout<<"★☆★ 抽籤中 ★☆★"<<endl;
  20.         cout<<name[ball]<<endl;
  21.         system("cls");        
  22.     }
  23.     cout<<"吃:"<<name[ball]<<"!"<<endl<<endl;
  24.     system ("pause");
  25.     return 0;
  26.            
  27. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[]={"被人告白","採到黃金","撿到一千元","被趕出家門","當上總統"};               
  7.     cout<<"☆★☆ 抽籤程式-神準算命 ☆★☆"<<endl<<endl;
  8.     int today;
  9.     srand(time(NULL));
  10.     system("pause");
  11.     for(int i=0; i<=150; i++)
  12.     {
  13.         today=rand()%5;
  14.         if(i%2==0)
  15.            cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;   
  16.         else
  17.            cout<<"★☆★ 抽籤中 ★☆★"<<endl;
  18.         cout<<name[today];
  19.         system("cls");
  20.     }
  21.     cout<<"你今天會: "<<name[today]<<"!"<<endl<<endl;
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"[幸運獎]狗","大象","毒蛇","刺蝟","獅子"};
  7.     int ball;
  8.     srand(time(NULL));
  9.     cout<<"◇◆◇抽籤程式◇◆◇"<<endl;
  10.     cout<<"今把天你要哪種動物抱起來?"<<endl;
  11.     system("pause");
  12.     system("cls");
  13.     for(int i=0; i<=150; i++)
  14.     {
  15.         ball=rand()%5;
  16.         if(i%2==0)
  17.                cout<<"▁ ▂ ▃ 抽籤中!!"<<endl;            
  18.         else   
  19.                cout<<"▅ ▆ ▇ 抽籤中!!"<<endl;
  20.         cout<<name[ball]<<endl;
  21.         system("cls");                                    
  22.     }
  23.     cout<<"今天要把"<<name[ball]<<"抱起來"<<endl<<endl;
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[6]={"六福村","九族文化村","劍湖山","溪頭妖怪村","麗寶樂園","義大世界"};
  7.     int a;
  8.     srand(time(NULL));
  9.     cout<<"\/\/\/\/ 抽籤程式 \/\/\/\/"<<endl;
  10.     cout<<"明天要去哪裡玩?"<<endl<<endl;
  11.     system("pause");
  12.     system("cls");
  13.     for(int i=0; i<=150; i++)
  14.     {
  15.         a=rand()%6;
  16.         if(i%2==0)
  17.             cout<<"//////// 抽籤中 \\\\\\\\"<<endl;
  18.         else
  19.             cout<<"\\\\\\\\ 抽籤中 ////////"<<endl;
  20.         cout<<name[a]<<endl;
  21.         system("cls");
  22.     }
  23.     cout<<"去"<<name[a]<<"!"<<endl<<endl;
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[6]={"畫畫","看書","玩電腦","逛街","看電影","看電視"};
  7.     int ball;
  8.     srand(time(NULL));
  9.     cout<<"☆★☆ 抽籤程式 ☆★☆"<<endl;
  10.     cout<<"今天晚上要做什麼?"<<endl<<endl;
  11.     system("pause");
  12.     system("cls");
  13.     for(int i=0; i<=150; i++)
  14.     {
  15.             ball=rand()%6;
  16.             if(i%2==0)
  17.                  cout<<"☆★☆ 抽籤中 ☆★☆"<<endl;
  18.             else
  19.                  cout<<"★☆★ 抽籤中 ★☆★"<<endl;
  20.             cout<<name[ball]<<endl;
  21.             system("cls");            
  22.     }
  23.     cout<<"今天晚上要:"<<name[ball]<<"!"<<endl<<endl;
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

返回列表