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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 拆分數組并將第一部分添加到末尾 > 原文: [https://www.geeksforgeeks.org/split-array-add-first-part-end/](https://www.geeksforgeeks.org/split-array-add-first-part-end/) 有一個給定的數組,并將其從指定位置拆分,然后將數組的第一部分加到末尾。 ![Split the array and add the first part to the end](https://img.kancloud.cn/c8/95/c895a6d5864af4635cee7ef55bfb33a2_743x568.png) **示例**: ``` Input : arr[] = {12, 10, 5, 6, 52, 36} k = 2 Output : arr[] = {5, 6, 52, 36, 12, 10} Explanation : Split from index 2 and first part {12, 10} add to the end . Input : arr[] = {3, 1, 2} k = 1 Output : arr[] = {1, 2, 3} Explanation : Split from index 1 and first part add to the end. ``` **簡單解決方案** 我們一對一旋轉數組。 ## C++ ```cpp // CPP program to split array and move first // part to end. #include <bits/stdc++.h> using namespace std; void splitArr(int arr[], int n, int k) { ????for (int i = 0; i < k; i++) { ????????// Rotate array by 1\. ????????int x = arr[0]; ????????for (int j = 0; j < n - 1; ++j) ????????????arr[j] = arr[j + 1]; ????????arr[n - 1] = x; ????} } // Driver code int main() { ????int arr[] = { 12, 10, 5, 6, 52, 36 }; ????int n = sizeof(arr) / sizeof(arr[0]); ????int position = 2; ????splitArr(arr, 6, position); ????for (int i = 0; i < n; ++i) ????????printf("%d ", arr[i]); ????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>

                              哎呀哎呀视频在线观看