<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 矩陣中第一行和最后一行的交換元素 > 原文: [https://www.geeksforgeeks.org/interchange-elements-of-first-and-last-rows-in-matrix/](https://www.geeksforgeeks.org/interchange-elements-of-first-and-last-rows-in-matrix/) 給定 4 x 4 矩陣,我們必須交換第一行和最后一行的元素,并顯示結果矩陣。 **示例**: ``` Input : 3 4 5 0 2 6 1 2 2 7 1 2 2 1 1 2 Output : 2 1 1 2 2 6 1 2 2 7 1 2 3 4 5 0 Input : 9 7 5 1 2 3 4 1 5 6 6 5 1 2 3 1 Output : 1 2 3 1 2 3 4 1 5 6 6 5 9 7 5 1 ``` 該方法非常簡單,我們可以簡單地交換矩陣第一行和最后一行的元素,以獲取所需的矩陣作為輸出。 下面是該方法的實現: ## C++ ```cpp // C++ code to swap the element of first // and last row and display the result #include <iostream> using namespace std; #define n 4 void interchangeFirstLast(int m[][n]) { ????????int rows = n; ????????// swapping of element between first ????????// and last rows ????????for (int i = 0; i < n; i++) ????????{ ????????????int t = m[0][i]; ????????????m[0][i] = m[rows - 1][i]; ????????????m[rows - 1][i] = t; ????????} }? // Driver function int main() { ????// input in the array ????int m[n][n] = { { 8, 9, 7, 6 }, ????????????????{ 4, 7, 6, 5 }, ????????????????{ 3, 2, 1, 8 }, ????????????????{ 9, 9, 7, 7 } };? ????interchangeFirstLast(m);? ????// printing the interchanged matrix ????for (int i = 0; i < n; i++) ????{ ????????for (int j = 0; j < n; j++)? ????????????cout << m[i][j] << " "; ????????cout << endl; ????} } // This code is contributed by Anant Agarwal. ```
                  <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>

                              哎呀哎呀视频在线观看