久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='4cgq1'><tr id='4cgq1'><dt id='4cgq1'><q id='4cgq1'><span id='4cgq1'><b id='4cgq1'><form id='4cgq1'><ins id='4cgq1'></ins><ul id='4cgq1'></ul><sub id='4cgq1'></sub></form><legend id='4cgq1'></legend><bdo id='4cgq1'><pre id='4cgq1'><center id='4cgq1'></center></pre></bdo></b><th id='4cgq1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4cgq1'><tfoot id='4cgq1'></tfoot><dl id='4cgq1'><fieldset id='4cgq1'></fieldset></dl></div>
<tfoot id='4cgq1'></tfoot>

  • <small id='4cgq1'></small><noframes id='4cgq1'>

    1. <legend id='4cgq1'><style id='4cgq1'><dir id='4cgq1'><q id='4cgq1'></q></dir></style></legend>

        <bdo id='4cgq1'></bdo><ul id='4cgq1'></ul>

        Rand() % 14 只生成值 6 或 13

        Rand() % 14 only generates the values 6 or 13(Rand() % 14 只生成值 6 或 13)
        <i id='zQwjU'><tr id='zQwjU'><dt id='zQwjU'><q id='zQwjU'><span id='zQwjU'><b id='zQwjU'><form id='zQwjU'><ins id='zQwjU'></ins><ul id='zQwjU'></ul><sub id='zQwjU'></sub></form><legend id='zQwjU'></legend><bdo id='zQwjU'><pre id='zQwjU'><center id='zQwjU'></center></pre></bdo></b><th id='zQwjU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zQwjU'><tfoot id='zQwjU'></tfoot><dl id='zQwjU'><fieldset id='zQwjU'></fieldset></dl></div>

            • <bdo id='zQwjU'></bdo><ul id='zQwjU'></ul>
                  <tbody id='zQwjU'></tbody>
                <tfoot id='zQwjU'></tfoot>

              • <small id='zQwjU'></small><noframes id='zQwjU'>

                <legend id='zQwjU'><style id='zQwjU'><dir id='zQwjU'><q id='zQwjU'></q></dir></style></legend>

                  本文介紹了Rand() % 14 只生成值 6 或 13的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  每當我運行以下程序時,返回的值總是 6 或 13.

                  Whenever I run the following program the returned values are always 6 or 13.

                  #include <iostream>
                  #include <fstream>
                  #include <ctime>
                  #include <cstdlib>
                  using namespace std;
                  
                  //void randomLegs();
                  //void randomPush();
                  //void randomPull();
                  //void randomMisc();
                  
                  
                  int main(int argc, const char * argv[])
                  {
                      srand(time(NULL));
                      //randomLegs();
                      cout << rand() % 14;
                      return 0;
                  }
                  

                  今天和昨天我已經運行了將近一百次這個程序.

                  I have run the program close to a hundred times during today and yesterday.

                  誰能告訴我我做錯了什么?

                  Can anyone tell me what I'm doing wrong?

                  謝謝.

                  順便說一下,如果我將 rand() 的范圍更改為 13 或 15,它就可以正常工作.

                  By the way, if I change the range of rand() to say 13 or 15 it works just fine.

                  推薦答案

                  我可以使用 Xcode 5 在 Mac OS X 10.9 上重現該問題 - 看起來它實際上可能是一個錯誤,或者至少是 的限制rand()/srand() 在 OS X 10.9 上.

                  I can reproduce the problem on Mac OS X 10.9 with Xcode 5 - it looks like it might actually be a bug, or at least a limitation with rand()/srand() on OS X 10.9.

                  我建議您使用 arc4random()相反,它比 rand() 效果更好,并且不需要隨機化種子:

                  I recommend you use arc4random() instead, which works a lot better than rand(), and which doesn't require that you randomize the seed:

                  #include <iostream>
                  #include <cstdlib>
                  
                  using namespace std;
                  
                  int main(int argc, const char * argv[])
                  {
                      cout << (arc4random() % 14) << endl;
                      return 0;
                  }
                  

                  測試:

                  $ g++ -Wall -O3 srand.cpp && ./a.out
                  5
                  $ ./a.out
                  8
                  $ ./a.out
                  0
                  $ ./a.out
                  8
                  $ ./a.out
                  11
                  $ ./a.out
                  8
                  $ ./a.out
                  3
                  $ ./a.out
                  13
                  $ ./a.out
                  9
                  $
                  

                  這篇關于Rand() % 14 只生成值 6 或 13的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  read input files, fastest way possible?(讀取輸入文件,最快的方法?)
                  The easiest way to read formatted input in C++?(在 C++ 中讀取格式化輸入的最簡單方法?)
                  Reading from .txt file into two dimensional array in c++(從 .txt 文件讀取到 C++ 中的二維數組)
                  How to simulate a key press in C++(如何在 C++ 中模擬按鍵按下)
                  Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(為什么在 cin.ignore() 之后沒有 getline(cin, var) 讀取字符串的第一個字符?)
                  What is the cin analougus of scanf formatted input?(scanf 格式輸入的 cin 類比是什么?)
                  • <bdo id='QCUZa'></bdo><ul id='QCUZa'></ul>
                      <tbody id='QCUZa'></tbody>
                    <legend id='QCUZa'><style id='QCUZa'><dir id='QCUZa'><q id='QCUZa'></q></dir></style></legend>
                  • <i id='QCUZa'><tr id='QCUZa'><dt id='QCUZa'><q id='QCUZa'><span id='QCUZa'><b id='QCUZa'><form id='QCUZa'><ins id='QCUZa'></ins><ul id='QCUZa'></ul><sub id='QCUZa'></sub></form><legend id='QCUZa'></legend><bdo id='QCUZa'><pre id='QCUZa'><center id='QCUZa'></center></pre></bdo></b><th id='QCUZa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QCUZa'><tfoot id='QCUZa'></tfoot><dl id='QCUZa'><fieldset id='QCUZa'></fieldset></dl></div>
                  • <tfoot id='QCUZa'></tfoot>

                          1. <small id='QCUZa'></small><noframes id='QCUZa'>

                            主站蜘蛛池模板: 日日操操| 91视频在线看 | 91久久国产精品 | 国产一区二区三区四区五区加勒比 | 精品久久久久久久久久久久 | 黄免费观看视频 | 国产精品免费看 | 男女午夜激情视频 | 亚洲一区二区三区四区五区中文 | 99免费在线视频 | 日日综合 | 久久69精品久久久久久久电影好 | 毛片免费观看 | 国产在线二区 | 国产精品久久一区二区三区 | 精品国产乱码久久久久久丨区2区 | 日本一区二区高清视频 | 天堂av中文在线 | 国产精品一区二区无线 | 午夜在线视频 | 黄色免费三级 | 97久久精品 | 中文字幕在线一区二区三区 | 99福利在线观看 | 91精品国产综合久久久久 | 日本三级网站在线观看 | 日本午夜网站 | 亚洲精品乱码8久久久久久日本 | 在线观看中文字幕 | 96av麻豆蜜桃一区二区 | 毛片免费视频 | 亚洲在线中文字幕 | 亚洲综合久久久 | 一区二区伦理电影 | www.887色视频免费 | 亚洲欧美成人在线 | 久久一二| 日韩欧美精品在线播放 | 97日日碰人人模人人澡分享吧 | 国产亚洲欧美在线 | 欧美一区在线视频 |