Reference no: EM132164434
Using C++
Part A. Write a function that takes at least two parameters: a string S, and an array of strings A.
It should search through A to see if S appears anywhere in it. If S is found, the function should return its position (remember that the first position in an array is numbered 0). If S is not found, the function should return -1. so in this context
void main()
{ string names[] = { "Jilly", "Joe", "Jim", "Jenny", "Jemimah" };
int p = find("Jenny", names, ...);
p should be set to 3.
Part B. Write another function that takes at least two parameters: an integer position P, and an array of strings A.
It should change the array A by "removing" the string which is at position P. Of course, you can't just leave a hole in an array.
Removing a string is achieved by moving all following strings up by one position so that the unwanted one is overwritten, and noting that the array is now a little shorter than it used to be. so after doing this
void main() {
string names[] = { "Jilly", "Joe", "Jim", "Jenny", "Jemimah" };
remove(2, names, ...);
names should contain "Jilly", "Joe", "Jenny", and "Jemimah".
Part C. Making use of your answers to parts A and B, write another function that takes two arrays of strings.
It should modify the first array by removing from it any string that appears anywhere in the second array.
Think before writing. There is a very easy way to do this.