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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ###JAVA版 ~~~ public class Merge { //合并有序數組 public static void mergeSort(int a[], int b[], int c[]) { int n = a.length, m = b.length; int i, j, k; i = j = k = 0; while (i < n && j < m) { if (a[i] < b[j]) { c[k++] = a[i++]; } else { c[k++] = b[j++]; } } while (i < n) c[k++] = a[i++]; while (j < m) c[k++] = b[j++]; } //打印數組中的元素 public static void printArr(int a[]) { for (int i = 0; i < a.length; i++) { System.out.print(a[i] + "\t"); } } public static void main(String[] args) { System.out.println("Hello World!"); int[] a = new int[] { 1, 2, 5, 6 }; int[] b = new int[] { 3, 8, 9, 10 }; int c[] = new int[8]; mergeSort(a, b, c); printArr(c); } } 輸出結果: 1 2 3 5 6 8 9 10 ~~~ ###C語言版 ~~~ #include <stdio.h> // 打印數組a void printArr(int a[],int n){ for (int i = 0; i < n; ++i) { printf("%d\t",a[i]); } printf("\n"); } //合并有序數組 void mergeArray(int a[],int n,int b[],int m,int c[]){ int i, j, k; i = j = k = 0; while (i <n && j<m) { if (a[i] < b[j]) c[k++] = a[i++]; else c[k++] = b[j++]; } while (i < n) c[k++] = a[i++]; while (j < m) c[k++] = b[j++]; } int main(){ int a[3]={2,3,6}; int b[2]={1,5}; int c[5]={}; mergeArray(a,3,b,2,c); printArr(c,5); } 輸出結果: yaopans-MacBook-Pro:algorithm yaopan$ ./a.out 1 2 3 5 6 ~~~
                  <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>

                              哎呀哎呀视频在线观看