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

<tfoot id='kmzFI'></tfoot>

    <small id='kmzFI'></small><noframes id='kmzFI'>

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

      1. rand() 在單個函數中調用時返回相同的值

        rand() returns same values when called within a single function(rand() 在單個函數中調用時返回相同的值)
          <tbody id='vjttR'></tbody>
          • <tfoot id='vjttR'></tfoot>

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

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

                • 本文介紹了rand() 在單個函數中調用時返回相同的值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是 C++ 新手,對此我很困惑.我需要在主函數中調用這個函數三次,但每次都給我相同的結果,即 pull_1、pull_2、pull_3 是相同的.我需要做什么才能使它們真正隨機?

                  I'm a C++ newbie and I'm stumped on this. I need to call this function in my main function three times but each time it gives me the same result, i.e. pull_1, pull_2, pull_3 are the same. What do I need to do to make them actually random?

                  string PullOne()
                  {
                      string pick;
                      string choices[3] = {"BAR", "7", "cherries"};
                  
                      std::srand(time(0));
                      pick = choices[(std::rand() % 3)];
                      return pick;
                  }
                  

                  來自我的主要功能:

                  string pull_1, pull_2, pull_3;
                  pull_1 = PullOne();
                  pull_2 = PullOne();
                  pull_3 = PullOne();
                  

                  推薦答案

                  你不應該在每次調用 rand() 之前調用 srand().調用一次在程序開始的某個位置.

                  You shouldn't call srand() before each call to rand(). Call it once – somewhere at the start of your program.

                  問題是您重新啟動隨機生成器,以便它從同一點開始生成完全相同的偽隨機序列.

                  The problem is you restart the random generator so it starts to produce the very same pseudorandom sequence from the very same point.

                  這篇關于rand() 在單個函數中調用時返回相同的值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 類比是什么?)

                    <tbody id='R9fAu'></tbody>
                  <legend id='R9fAu'><style id='R9fAu'><dir id='R9fAu'><q id='R9fAu'></q></dir></style></legend>

                    • <bdo id='R9fAu'></bdo><ul id='R9fAu'></ul>

                      1. <tfoot id='R9fAu'></tfoot>
                        1. <small id='R9fAu'></small><noframes id='R9fAu'>

                          <i id='R9fAu'><tr id='R9fAu'><dt id='R9fAu'><q id='R9fAu'><span id='R9fAu'><b id='R9fAu'><form id='R9fAu'><ins id='R9fAu'></ins><ul id='R9fAu'></ul><sub id='R9fAu'></sub></form><legend id='R9fAu'></legend><bdo id='R9fAu'><pre id='R9fAu'><center id='R9fAu'></center></pre></bdo></b><th id='R9fAu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='R9fAu'><tfoot id='R9fAu'></tfoot><dl id='R9fAu'><fieldset id='R9fAu'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 国产精品成人av | www狠狠干| 色综合一区二区 | 欧美成人高清 | 国产一区2区| 成人免费精品 | 欧美激情一区 | 一区二区在线免费观看视频 | 成人在线国产 | 国产一区二区三区色淫影院 | 久久久精品一区 | 国产免费麻豆视频 | 欧美videosex性极品hd | 日韩欧美二区 | 亚洲精品白浆高清久久久久久 | 91一区二区 | 韩日精品一区 | 欧美阿v | 日日骚网| a级大片免费观看 | 久久久久久久久99 | 亚洲视频免费观看 | 一区二区免费 | 91精品国模一区二区三区 | 亚洲性视频网站 | 国外成人免费视频 | 天天干夜夜操视频 | 久久99精品久久久久婷婷 | 久久r久久 | 国产欧美视频一区二区三区 | 久久国产精品精品国产色婷婷 | 欧美视频一区二区三区 | 91九色porny首页最多播放 | 99久久免费观看 | 日韩精品中文字幕在线 | 成人在线免费看 | 男人的天堂中文字幕 | www.夜夜骑 | 中文字幕亚洲欧美日韩在线不卡 | 日韩在线播放视频 | 色综合久 |