Swap Two Arrays
mediumQuestion 543The code already creates array<int, 3> a = {1, 2, 3}; and array<int, 3> b = {4, 5, 6};.
Swap the contents of a and b with a single call to the swap member function (no element-by-element loop), then print both arrays: the first line is the text a: followed by a space and the elements of a separated by spaces; the second line is b: followed by a space and the elements of b.
Expected output
a: 4 5 6 b: 1 2 3
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL Containersstd::array
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.