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

      <bdo id='FXJvI'></bdo><ul id='FXJvI'></ul>
    <legend id='FXJvI'><style id='FXJvI'><dir id='FXJvI'><q id='FXJvI'></q></dir></style></legend>

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

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

        如何在 C++ 中創(chuàng)建多個向量的組合而無需硬編碼循

        Howto create combinations of several vectors without hardcoding loops in C++?(如何在 C++ 中創(chuàng)建多個向量的組合而無需硬編碼循環(huán)?)
      2. <small id='z9JBT'></small><noframes id='z9JBT'>

          <bdo id='z9JBT'></bdo><ul id='z9JBT'></ul>

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

              • <legend id='z9JBT'><style id='z9JBT'><dir id='z9JBT'><q id='z9JBT'></q></dir></style></legend>
                  <tfoot id='z9JBT'></tfoot>
                  本文介紹了如何在 C++ 中創(chuàng)建多個向量的組合而無需硬編碼循環(huán)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我有幾個看起來像這樣的數(shù)據(jù):

                  I have several data that looks like this:

                  Vector1_elements = T,C,A
                  Vector2_elements = C,G,A
                  Vector3_elements = C,G,T
                  ..... up to ...
                  VectorK_elements = ...
                  
                  #Note also that the member of each vector is always 3.
                  

                  我想要做的是在 Vector1 到 VectorK 中創(chuàng)建所有元素組合.因此最終我們希望得到這個輸出(使用 Vector1,2,3):

                  What I want to do is to create all combination of elements in Vector1 through out VectorK. Hence in the end we hope to get this output (using Vector1,2,3):

                  TCC
                  TCG
                  TCT
                  TGC
                  TGG
                  TGT
                  TAC
                  TAG
                  TAT
                  CCC
                  CCG
                  CCT
                  CGC
                  CGG
                  CGT
                  CAC
                  CAG
                  CAT
                  ACC
                  ACG
                  ACT
                  AGC
                  AGG
                  AGT
                  AAC
                  AAG
                  AAT
                  

                  我現(xiàn)在遇到的問題是我的以下代碼通過對循環(huán)進行硬編碼來實現(xiàn).由于向量的數(shù)量可以變化,我們需要一種靈活的方法來獲得相同的結(jié)果.有嗎?

                  The problem I am having now is that the following code of mine does that by hardcoding the loops. Since number of Vectors can be varied, we need a flexible way to get the same result. Is there any?

                  我的這段代碼最多只能處理 3 個向量(硬編碼):

                  This code of mine can only handle up to 3 Vectors (hardcoded):

                  #include <iostream>
                  #include <vector>
                  #include <fstream>
                  #include <sstream>
                  using namespace std;
                  
                  
                  int main  ( int arg_count, char *arg_vec[] ) {
                  
                      vector <string> Vec1;
                            Vec1.push_back("T");
                            Vec1.push_back("C");
                            Vec1.push_back("A");
                  
                      vector <string> Vec2;
                            Vec2.push_back("C");
                            Vec2.push_back("G");
                            Vec2.push_back("A");
                  
                      vector <string> Vec3;
                            Vec3.push_back("C");
                            Vec3.push_back("G");
                            Vec3.push_back("T");
                  
                  
                  
                       for (int i=0; i<Vec1.size(); i++) {
                          for (int j=0; j<Vec2.size(); j++) {
                              for (int k=0; k<Vec1.size(); k++) {
                                  cout << Vec1[i] << Vec2[i] << Vec3[k] << endl;
                              }
                          }
                       }
                  
                  
                  
                      return 0;
                  }
                  

                  推薦答案

                  這樣做可以解決問題:

                  void printAll(const vector<vector<string> > &allVecs, size_t vecIndex, string strSoFar)
                  {
                      if (vecIndex >= allVecs.size())
                      {
                          cout << strSoFar << endl;
                          return;
                      }
                      for (size_t i=0; i<allVecs[vecIndex].size(); i++)
                          printAll(allVecs, vecIndex+1, strSoFar+allVecs[vecIndex][i]);
                  }
                  

                  致電:

                  printAll(allVecs, 0, "");
                  

                  這篇關(guān)于如何在 C++ 中創(chuàng)建多個向量的組合而無需硬編碼循環(huán)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                  When and how should I use exception handling?(我應(yīng)該何時以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對象的范圍)
                  Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)
                  Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別)

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

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

                  1. <tfoot id='WAF4j'></tfoot>
                        • <bdo id='WAF4j'></bdo><ul id='WAF4j'></ul>

                            主站蜘蛛池模板: 男女免费观看在线爽爽爽视频 | 成人黄色av | 一区二区三区免费网站 | 国产欧美日韩一区二区三区在线 | 欧美男人天堂 | 久久久久久国模大尺度人体 | 精品久久精品 | 免费黄网站在线观看 | 色播久久 | 国产一区二区三区在线 | 国产在线精品一区二区三区 | 日本激情视频网 | 精品视频成人 | 亚洲日日操 | 亚洲精品九九 | 国产精品一区久久久久 | 成人日韩| 国产精品久久久久久久免费大片 | 精品欧美一区二区三区久久久 | 天天影视网天天综合色在线播放 | 国产精品精品视频一区二区三区 | 亚洲视频观看 | 国产一区二区三区高清 | 黄免费观看视频 | 久久伊人亚洲 | 久久久久国产精品 | 伊人欧美视频 | 中文字幕视频在线观看免费 | 午夜三级在线观看 | 久久人人网 | 美国一级黄色片 | 久久精品亚洲欧美日韩久久 | 午夜欧美a级理论片915影院 | 午夜欧美 | 免费视频成人国产精品网站 | 国产视频亚洲视频 | 91日韩 | 国产精品综合视频 | 久久久久国产一区二区三区四区 | 2019天天操 | 99热最新|