Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*Please utilize C++ format when answering questions 44. a) Write a function that

ID: 3626485 • Letter: #

Question

*Please utilize C++ format when answering questions

44. a) Write a function that passes in 2 vectors of strings and returns true if they are equal and false otherwise. For this function, equal means the 2 vectors have the exact same values in the exact same order. This also implies that the vectors must store the exact same number of values.

b) Write a main function that tests this function at least once. For the vectors, you may initialize it with any values you choose, but you must give each at least 2 values.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <vector>
using namespace std;
bool compare2(vector<string>,vector<string>);
int main()
{vector <string> a,b;
int n;
string s;
cout<<"how many elements in vector a: ";
cin>>n;
while(n<2)
   {cout<<"must be at least 2 how many elements in vector a: ";
    cin>>n;
    }
for(int i=0;i<n;i++)
   {cout<<"enter a string: ";
   cin>>s;
    a.push_back(s);
    }
cout<<"how many elements in vector b: ";
cin>>n;
while(n<2)
   {cout<<"must be at least 2 how many elements in vector a: ";
    cin>>n;
    }
for(int i=0;i<n;i++)
   {cout<<"enter a string: ";
   cin>>s;
    b.push_back(s);
    }  
if(compare2(a,b))
   cout<<"The vectors are the same"<<endl;
else
   cout<<"The vectors are different"<<endl;
system("pause");
return 0;
}
bool compare2(vector<string> a,vector<string> b)
{string s1,s2;
if(a.size()!=b.size())
     return false;
for(int i=0;i<a.size();i++)
     if(a[i].compare(b[i])!=0)
         return false;
return true;
}