← Back to STL Containers
Question 545
Compare Two Arrays
Compare Two Arrays
Write a functionbool sameContents(const array<int, 4>& a, const array<int, 4>& b)that returnstruewhen the two arrays hold the same values in the same order andfalseotherwise. The test prints the wordsamewhen your function returns true anddifferentwhen it returns false, one result per line. For {1, 2, 3, 4} compared with {1, 2, 3, 4} it prints the output shown in Expected Output. Do NOT write a main function.
Expected Output:
same different different
= newline. The output ends with a newline — print one after the last line.
Hints2 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.