Given an array of strings and a string s, return the average length of all strings containing s.

Complete the following file:

prog.cpp

#include <iostream> #include <string> using namespace std; /** Returns the index of the first occurrence of t in s, or -1 if t doesn't occur in s. */ int find(string s, string t) { for (int i = 0; i + t.length() <= s.length(); i++) { if (s.substr(i, t.length()) == t) { return i; } } return -1; } double averageLengthOfStringsContaining(const string arr[], int arr_size, string s) {
}

Use the following file:

Tester.cpp

#include <iostream>
using namespace std;

double averageLengthOfStringsContaining(const string arr[], int arr_size, string s);

int main()
{   
   const string arr1[] = { "hello","hi", "here", "there", "their"};
   double result = averageLengthOfStringsContaining(arr1, 5, "he");
   cout << result << endl;
   cout << "Expected: 4.75" << endl;

   const string arr2[] = { "hello","hi", "there", "bye"};
   result = averageLengthOfStringsContaining(arr2, 4, "hi");
   cout << result << endl;
   cout << "Expected: 2" << endl;

   result = averageLengthOfStringsContaining(arr2, 4, "ho");
   cout << result << endl;
   cout << "Expected: 0" << endl;
   
   return 0;
}