C++ Please explain the code below. It doesn't have to be long, as long as you explain what the important parts of the code do. You can also explain it line by line for best ratings. Thank you so much! #include using namespace std; void combine(int*, int*, int, int*, int); int main(void) { // Hey there, start typing your C++ code here... int size1, size2; cin >> size1; int arr1[size1]; for (int i = 0; i < size1; i++) { cin >> arr1[i]; } cin >> size2; int arr2[size2]; for (int i = 0; i < size2; i++) { cin >> arr2[i]; } int comb_size = size1 + size2; int comb_arr[comb_size]; combine(comb_arr, arr1, size1, arr2, size2); for (int i = 0; i < comb_size; i++) { printf("%d ", *(comb_arr+i)); } return 0; } // EXACT RUNNING TIME = ______ // BIG OH RUNNING TIME = ______ void combine(int* combine, int* arr1, int n, int* arr2, int m) { int temp = 0; for(int i = 0; i
C++ Please explain the code below.
It doesn't have to be long, as long as you explain what the important parts of the code do. You can also explain it line by line for best ratings. Thank you so much!
#include <iostream>
using namespace std;
void combine(int*, int*, int, int*, int);
int main(void) {
// Hey there, start typing your C++ code here...
int size1, size2;
cin >> size1;
int arr1[size1];
for (int i = 0; i < size1; i++) {
cin >> arr1[i];
}
cin >> size2;
int arr2[size2];
for (int i = 0; i < size2; i++) {
cin >> arr2[i];
}
int comb_size = size1 + size2;
int comb_arr[comb_size];
combine(comb_arr, arr1, size1, arr2, size2);
for (int i = 0; i < comb_size; i++) {
printf("%d ", *(comb_arr+i));
}
return 0;
}
// EXACT RUNNING TIME = ______
// BIG OH RUNNING TIME = ______
void combine(int* combine, int* arr1, int n, int* arr2, int m) {
int temp = 0;
for(int i = 0; i<n; i++){
*(combine+i) = arr1[i];
temp++;
}
for(int j=0; j<m; j++){
*(combine+j+temp) = arr2[j];
}
}
Step by step
Solved in 2 steps with 2 images