Hi I'm getting error messages with my implementation of the random generator. The error message is written in comments beside the random generator. Can anyone help me check what is the problem? I'm tasked to generate 2 sets of vectors and compare if they are the same (have the same numbers, duplicates are ignored).
//function
bool same_set(vector<int> setA, vector<int> setB) {
//Sorting SetA
bool swapped=true;
while (swapped==true) {
swapped=false;
for (int i=0; i<setA.size();i++) {
if (setA[i]>setA[i+1]) {
swap(setA[i],setA[i+1]);
swapped = true;
}
}
}
//Sort setB
swapped=true;
while (swapped==true) {
swapped=false;
for (int i=0; i<setB.size();i++) {
if (setB[i]>setB[i+1]) {
swap(setB[i],setB[i+1]);
swapped = true;
}
}
}
//Delete duplicates in SetA
bool deleted=true;
while (deleted == true) {
deleted = false;
for (long j=setA.size()-1; j>=0;j--) {
if (setA[j]==setA[j-1]) {
setA.erase(setA.end());
deleted = true;
}
}
deleted =true;
}
//Delete duplicates in SetB
while (deleted == true) {
deleted = false;
for (long j=setA.size()-1; j>=0;j--) {
if (setA[j]==setA[j-1]) {
setA.erase(setA.end());
deleted = true;
}
}
}
//Check if both sets have the same size. If they don't: false.
if (setA.size()!=setB.size()) {
returnfalse;
}
//Check if they match term for term. If they dont, false.
for (int i=0; i<setA.size(); i++) {
if (setA[i]!=setB[i]) {
returnfalse;
}
}
returntrue;
}