How can I finish my code below? Where should I add isEmpty? And how to just print "The Intersected Elements of Set A and B are:" once only?
#include <iostream>
using namespace std;
int main() {
int A[10], B[10];
cout << "Enter 10 Elements of Set A:" << endl;
for (int i = 0; i < 10; i++) {
cin >> A[i];
}
cout << "Enter 10 Elements of Set B:" << endl;
for (int i = 0; i < 10; i++) {
cin >> B[i];
}
bool isFirstIntersectedElem = true;
bool isEmpty = true;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (A[i] == B[j]) {
for (int i = 0; i < 10 && isFirstIntersectedElem; i++) {
if (A[i] != B[i]) {
isFirstIntersectedElem = false;
}
}
if (isFirstIntersectedElem) {
cout << "The Intersected Elements of Set A and B are:" << endl;
cout << A[i] << " ";
}
else {
cout << "The IntersectedElement of Set A and B are not Found.";
}
}
}
}
return 0;
}
Here is the expected output: (https://i.stack.imgur.com/7cPvX.png)