It is necessary to combine two arrays into one and leave only non-common elements in it. For example, arr1 {1,2,3,4} + arr2 {1,1,5,6}, the result is arr3 {3,4,6}.
const int SIZE1 = 8; const int SIZE2 = 5; int arr1[SIZE1] = { 0 }; int arr2[SIZE2] = { 0 }; cout << "First array\n"; for (int i = 0; i < SIZE1; i++){ arr1[i] = rand() % 20; cout << arr1[i] << '\t'; } cout << "\nSecond array\n"; for (int i = 0; i < SIZE2; i++){ arr2[i] = rand() % 20; cout << arr2[i] << '\t'; } cout << endl; const int SIZE3 = SIZE1 + SIZE2; int arr3[SIZE3] = { 0 }; cout << "Third array\n"; for (int i = 0; i < SIZE3; i++){ arr3[i] = arr1[i]; if (i >= SIZE1) arr3[i] = arr2[i-SIZE1]; cout << arr3[i] << '\t'; } cout << endl; const int SIZE4 = SIZE3; int arr4[SIZE4] = { 0 }; int size4 = 0; for (int i = 0; i < SIZE4; i++){ for (int j = 0; j < SIZE4; j++){ if (arr3[i] == arr3[j]&&i!=j) break; else if (arr3[i] != arr3[j]&&j<SIZE4-1) continue; else if (arr3[i] != arr3[SIZE4-1]&&j==SIZE4-1) { arr4[size4] = arr3[i]; size4++; } } } cout << "Sorted array\n"; for (int i = 0; i < size4; i++){ cout << arr4[i] << '\t'; } cout << endl;
}