If it's possible to change the arrays, you can sort them first, and then check that they are equal. If you can't modify the arrays, you can create sorted copies.
Without sorting, one way might be to count the number of occurences of each value in both arrays:
1 2 3 4 5 6 7 8
for (int i = 0; i < 5; i++) {
int val = array1[i];
int count1 = std::count(array1, array1+5, val);
int count2 = std::count(array2, array2+5, val);
if (count1 != count2)
returnfalse; // not equal
}
returntrue; // equal