Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int array_a[] = { 1, 5 };
- int array_b[] = { 2, 3 };
- int size_a = sizeof( array_a ) / sizeof( array_a[0] );
- int size_b = sizeof( array_b ) / sizeof( array_b[0] );
- int total_size = size_a + size_b;
- int united_array[ total_size ];
- for (int i = 0; i < total_size; i++) {
- united_array[i] = (i < size_a ? array_a[i] : array_b[i - size_b]);
- }
- // Print array
- for (int i = 0; i < total_size; i++) {
- cout << united_array[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement