Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int smallSize{ 5 };
- const int bigSize{ smallSize * 2 };
- int arrA[smallSize]{1, 3, 5, 7, 9};
- int arrB[smallSize]{1, 4, 6, 7, 10};
- int arrC[bigSize]{};
- int idxA{ 0 };
- int idxB{ 0 };
- int idxC{ 0 };
- while (idxA < smallSize and idxB < smallSize)
- {
- arrC[idxC++] = arrA[idxA] < arrB[idxB] ? arrA[idxA++] : arrB[idxB++];
- }
- while (idxA < smallSize)
- {
- arrC[idxC++] = arrA[idxA++];
- }
- while (idxB < smallSize)
- {
- arrC[idxC++] = arrB[idxB++];
- }
- for (int idxC{ 0 }; idxC < bigSize; ++idxC)
- {
- std::cout << arrC[idxC] << ' ';
- }
- std::cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment