Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ PROGRAM create the function: int lookupAny(const string a1[], int n1, const string a2[], int n2); the functions has to look exactly like int

C++ PROGRAM 

create the function: int lookupAny(const string a1[], int n1, const string a2[], int n2); the functions has to look exactly like " int lookupAny(const string a1[], int n1, const string a2[], int n2);". please don't add or make any changes to it. I only need the function.

the functions you must write take 4 parameters. array of strings a1[] and a2[] , and the number of items function will consider in the arrays n1 and n2, starting from the beginning. Basically n1 is the number of interesting elements in a1, and n2 is the number of interesting elements in a2. So when we say "the array", we mean the n elements that the function is aware of. Return the smallest position in a1 of an element that is equal to any of the elements in a2. Return 1 if no element of a1 is equal to any element of a2. Also return -1 if n1 or n2 are negative. examples:

string names[10] = { "logan", "reed", "sue", "selina", "bruce", "peter" }; string set1[10] = { "clark", "bruce", "selina", "reed" }; string set2[10] = { "clark", "bruce", "peter", "reed" }; int v = lookupAny(names, 6, set1, 4); // returns 1 (a1 has "reed" there) int v = lookupAny(names, 5, set2, 4); // returns -1 (a1 has none) string set3[10] = { "tony", "diana" }; int w = lookupAny(names, 6, set3, 2); // returns -1 (a1 has none) 

--------------------------------------

another example:

string h[7] = { "selina", "reed", "diana", "tony", "", "logan", "peter" }; 
string f[3] = { "peter", "diana", "steve" }; 
assert(lookupAny(h, 7, f, 3) == 2); 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Let X have density Find E(X). for 3 < x < 4. otherwise. 0

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago