MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / merging

Function merging

Lab_08/Sort.cpp:5–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3// function for merging two arrays into third array
4
5void merging(int arr1[], int arr2[], int arr3[])
6{
7 int i = 0, j = 0, k = 0;
8 for (i = 0; i < 5 && j < 5;)
9 { // comparing first array elements with second
10 if (arr1[i] < arr2[j])
11 {
12 arr3[k] = arr1[i];
13 k++;
14 i++;
15 }
16 else
17 {
18 arr3[k] = arr2[j];
19 k++;
20 j++;
21 }
22 }
23 while (i < 5)
24 { // comparing for other elements of first and third arrays
25 arr3[k] = arr1[i];
26 k++;
27 i++;
28 }
29 while (j < 5)
30 { // comparing for other elements of second and third arrays
31 arr3[k] = arr2[j];
32 k++;
33 j++;
34 }
35}
36
37int main()
38{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected