<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Java 程序:查找矩陣轉置 > 原文: [https://www.programiz.com/java-programming/examples/transpose-matrix](https://www.programiz.com/java-programming/examples/transpose-matrix) #### 在此程序中,您將學習查找并打印 Java 中給定矩陣的轉置。 矩陣的轉置是將行交換為列的過程。 對于`2x3`矩陣, ```java Matrix a11 a12 a13 a21 a22 a23 Transposed Matrix a11 a21 a12 a22 a13 a23 ``` ## 示例:查找矩陣轉置的程序 ```java public class Transpose { public static void main(String[] args) { int row = 2, column = 3; int[][] matrix = { {2, 3, 4}, {5, 6, 4} }; // Display current matrix display(matrix); // Transpose the matrix int[][] transpose = new int[column][row]; for(int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { transpose[j][i] = matrix[i][j]; } } // Display transposed matrix display(transpose); } public static void display(int[][] matrix) { System.out.println("The matrix is: "); for(int[] row : matrix) { for (int column : row) { System.out.print(column + " "); } System.out.println(); } } } ``` 運行該程序時,輸出為: ```java The matrix is: 2 3 4 5 6 4 The matrix is: 2 5 3 6 4 4 ``` 在上述程序中,`display()`函數僅用于將矩陣的內容打印到屏幕上。 在此,給定矩陣的格式為`2x3`,即`row = 2`和`column = 3`。 對于轉置矩陣,我們將轉置順序更改為`3x2`,即`row = 3`和`column = 2`。 因此,我們有`transpose = int[column][row]` 矩陣的轉置是通過簡單地將列交換為行來計算的: ```java transpose[j][i] = matrix[i][j]; ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看