• <legend id='GVYou'><style id='GVYou'><dir id='GVYou'><q id='GVYou'></q></dir></style></legend>

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

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

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

        根据输入动态二维数组

        时间:2023-09-18

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

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

                  本文介绍了根据输入动态二维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要从用户那里得到一个输入 N 并生成一个 N*N 矩阵.我如何声明矩阵?一般来说,数组和矩阵的大小应该在声明时固定,对吗?vector> 怎么样?我以前从未使用过这个,所以我需要资深人士的建议.

                  I need to get an input N from the user and generate a N*N matrix. How can I declare the matrix? Generally, the size of the array and matrix should be fixed at the declaration, right? What about vector<vector<int>> ? I never use this before so I need suggestion from veteran.

                  推荐答案

                  Boost 在其 uBLAS 库,并提供如下使用语法.

                  Boost implements matrices (supporting mathematical operations) in its uBLAS library, and provides usage syntax like the following.

                  #include <boost/numeric/ublas/matrix.hpp>
                  
                  int main(int argc, char* argv[])
                  {
                      unsigned int N = atoi(argv[1]);
                      boost::matrix<int> myMatrix(N, N);
                  
                      for (unsigned i = 0; i < myMatrix.size1 (); ++i)
                          for (unsigned j = 0; j < myMatrix.size2 (); ++j)
                              myMatrix(i, j) = 3 * i + j;
                  
                      return 0;
                  }
                  

                  这篇关于根据输入动态二维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:什么是“条"?(GCC 应用程序)用于? 下一篇:Vector of Vectors 创建矩阵

                  相关文章

                  最新文章

                  <legend id='LSJFE'><style id='LSJFE'><dir id='LSJFE'><q id='LSJFE'></q></dir></style></legend>
                    <bdo id='LSJFE'></bdo><ul id='LSJFE'></ul>
                1. <small id='LSJFE'></small><noframes id='LSJFE'>

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

                      <tfoot id='LSJFE'></tfoot>