← Back to STL Containers
Question 543
Swap Two Arrays
Swap Two Arrays
The code already createsarray<int, 3> a = {1, 2, 3};andarray<int, 3> b = {4, 5, 6};. Swap the contents ofaandbwith a single call to theswapmember function (no element-by-element loop), then print both arrays: the first line is the texta:followed by a space and the elements ofaseparated by spaces; the second line isb:followed by a space and the elements ofb.
Expected Output:
a: 4 5 6 b: 1 2 3
= newline. The output ends with a newline — 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.