久久久久久久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)建多個(gè)向量的組合而無需硬編碼循

        Howto create combinations of several vectors without hardcoding loops in C++?(如何在 C++ 中創(chuàng)建多個(gè)向量的組合而無需硬編碼循環(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)建多個(gè)向量的組合而無需硬編碼循環(huán)?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我有幾個(gè)看起來像這樣的數(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)建所有元素組合.因此最終我們希望得到這個(gè)輸出(使用 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)在遇到的問題是我的以下代碼通過對(duì)循環(huán)進(jìn)行硬編碼來實(shí)現(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 個(gè)向量(硬編碼):

                  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)建多個(gè)向量的組合而無需硬編碼循環(huán)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時(shí),C++ 異常會(huì)以何種方式減慢代碼速度?)
                  Why catch an exception as reference-to-const?(為什么要捕獲異常作為對(duì) const 的引用?)
                  When and how should I use exception handling?(我應(yīng)該何時(shí)以及如何使用異常處理?)
                  Scope of exception object in C++(C++中異常對(duì)象的范圍)
                  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>

                            主站蜘蛛池模板: 日韩精品极品 | 日韩精品视频免费播放 | 亚洲视频区 | 欧美综合一区二区三区 | 18视频在线观看 | 日韩午夜av | 中文字幕在线观看免费视频 | 国产高清视频在线观看 | 日韩精品在线一区 | www.四虎.com| 日韩av一级片 | 欧美日韩91| 视频一二三区 | 青青草精品视频 | 国产成人免费视频 | 欧美一级淫片 | 99热国产在线 | 久久中文字幕视频 | 精品一区二区三区三区 | 日本免费在线观看视频 | 日皮视频免费看 | 久久久久免费 | 精品欧美一区二区精品久久 | 午夜影院在线 | 国产欧美日本 | 一区二区小视频 | 日本一区二区不卡视频 | 99热在线免费观看 | 成人福利在线观看 | 亚洲天天干 | 激情网站在线观看 | 色婷婷狠狠| 福利在线观看 | 日韩欧美国产精品 | 久久久精品一区二区 | 中文字幕一区二区三区四区视频 | 成人激情视频 | 99久久精品国产亚洲 | 中文字幕av久久爽av | 亚洲一区视频在线 | 欧美色偷偷 |