1 // 合并两个有序数组a和b到c 2 void Merge_Array(int a[], int n, int b[], int m, int c[]) 3 { 4 int i, j, k; 5 i = j = k = 0; 6 while(i < n && j < m) 7 { 8 if(a[i] < b[j]) 9 c[k++] = a[i++]; 10 else 11 c[k++] = b[j++]; 12 } 13 while(i < n) 14 c[k++] = a[i++]; 15 while(j < m) 16 c[k++] = b[j++]; 17 }
时间: 2024-10-27 08:45:16