diff --git a/Merge Two Sorted Arrays b/Merge Two Sorted Arrays new file mode 100644 index 0000000..db136b8 --- /dev/null +++ b/Merge Two Sorted Arrays @@ -0,0 +1,41 @@ +// C++ program to merge two sorted arrays +#include +#include +using namespace std; +void merge(int nums1[], int nums2[], int m, int n) { + //Creating an array of size m+n to store a merged array + int nums3[m+n]; + // copy nums1[] elements to nums3[] + for(int i=0;i=0;j--){ + //move elments one position ahead that are greater than current value + if(nums3[j]>temp){ + nums3[j+1]=nums3[j]; + } + else + break; + } + m=m+1; + //put Current element at its correct position. + nums3[j+1]=temp; + } + // printing the resultant array + cout << "Array after merging" <