void mergeArray(int arr1[], int n, int arr2[], int m, int arr3[]) {
int i, j, k;
i = j = k = 0;
while (i < n && j < m) {
if (arr1[i] < arr2[j]) {
arr3[k] = arr1[i];
k++;
i++;
} else {
arr3[k] = arr2[j];
k++;
j++;
}
}
while (i < n) {
arr3[k] = arr1[i];
i++;
k++;
}
while (j < m) {
arr3[k] = arr2[j];
k++;
j++;
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter