1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include<iostream>
using namespace std;
void merge(int A[], int B[], int C[], int m, int n, int &k);
int main(){
int A[100], B[100], C[100], n, m, k;
//int num1=0;
cout << " Enter number of element to enter in array 1: " << endl;
cin >> n;
cout << " Enter element in ascending order, ";
for (int i = 0; i < n; i++){
cout << "Enter a number " << i + 1 << ": ";
cin >> A[i];
//compare first to second input, and second to third
}
cout << "Enter number of element to enter in array 2: " << endl;
cin >> m;
cout << "Enter numbers in descending order, ";
for (int i = 0; i < m; i++)
{
cout << "Enter a number " << i + 1 << " :";
cin >> B[i];
// Compare first to second and second to third and so on
}
merge(A, B, C, n, m, k);
cout << " The Merging array in Ascending order: " << endl;
for (int i = 0; i < k; i++){
cout << C[i] << " ";
}
return 0;
}
}
void merge(int A[], int B[], int C[], int m, int n, int &k){
I know what to do here -
}
|