<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 以逆時針螺旋形式打印給定矩陣 > 原文: [https://www.geeksforgeeks.org/print-given-matrix-counter-clock-wise-spiral-form/](https://www.geeksforgeeks.org/print-given-matrix-counter-clock-wise-spiral-form/) 給定 2D 數組,以逆時針螺旋形式打印。 請參閱以下示例。 **示例**: ``` Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Output: 1 5 9 13 14 15 16 12 8 4 3 2 6 10 11 7 Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Output: 1 7 13 14 15 16 17 18 12 6 5 4 3 2 8 9 10 11 ``` **說明**: ![](https://img.kancloud.cn/5e/9c/5e9c1716917b0e40d203ddf6a7899deb_643x268.png) 下面是實現: ## C++ ```cpp // C++ implementation to print // the counter clock wise // spiral traversal of matrix #include <bits/stdc++.h> using namespace std; #define R 4 #define C 4 // function to print the // required traversal void counterClockspiralPrint(int m,? ?????????????????????????????int n,? ?????????????????????????????int arr[R][C]) { ????int i, k = 0, l = 0; ????//? k - starting row index ????//??? m - ending row index ????//??? l - starting column index ????//??? n - ending column index ????//??? i - iterator? ????// initialize the count ????int cnt = 0; ????// total number of? ????// elements in matrix ????int total = m * n; ????while (k < m && l < n)? ????{ ????????if (cnt == total) ????????????break; ????????// Print the first column? ????????// from the remaining columns ????????for (i = k; i < m; ++i) ????????{ ????????????cout << arr[i][l] << " "; ????????????cnt++; ????????} ????????l++; ????????if (cnt == total) ????????????break; ????????// Print the last row from ????????// the remaining rows? ????????for (i = l; i < n; ++i)? ????????{ ????????????cout << arr[m - 1][i] << " "; ????????????cnt++; ????????} ????????m--; ????????if (cnt == total) ????????????break; ????????// Print the last column? ????????// from the remaining columns? ????????if (k < m)? ????????{ ????????????for (i = m - 1; i >= k; --i)? ????????????{ ????????????????cout << arr[i][n - 1] << " "; ????????????????cnt++; ????????????} ????????????n--; ????????} ????????if (cnt == total) ????????????break; ????????// Print the first row? ????????// from the remaining rows? ????????if (l < n)? ????????{ ????????????for (i = n - 1; i >= l; --i)? ????????????{ ????????????????cout << arr[k][i] << " "; ????????????????cnt++; ????????????} ????????????k++; ????????} ????} } // Driver Code int main() { ????int arr[R][C] = {{ 1, 2, 3, 4 }, ?????????????????????{ 5, 6, 7, 8 }, ?????????????????????{ 9, 10, 11, 12 }, ?????????????????????{ 13, 14, 15, 16 }}; ????counterClockspiralPrint(R, C, arr); ????return 0; } ```
                  <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>

                              哎呀哎呀视频在线观看