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

//Can only use these libraries ( <array>, <deque>, <forward_list>, <list>, <map>

ID: 3837856 • Letter: #

Question

//Can only use these libraries ( <array>, <deque>, <forward_list>, <list>, <map>, <queue>, <set>, <stack>, <unordered_map>, <unordered_set>, <vector>), <algorithm>.)

Bonus: Find all occurrences of pairs of given strings in a vector of strings. countoccurrences @param segs: vector holding sequences of characters to be matched @param text: body of text to find matches in. All characters are a-z @return return a vector containing occurrence counts for each pair of sequences (counts should occur in the order sequences are given). sted: vectorkunsigned int> countoccurrences const std: :vector

Explanation / Answer

for( vector<string>::const_iterator it403 = vect00403.begin(); it403 != vect00403.end(); ++it403 ) // contains substrings

string text;
getline (cin, text);

string::size_type position = text.find (' ');
if (position != string::npos)
{
    if  (text.find (' ', position+1) != string::npos)
    {
        cout << "Contains at least two spaces!" << endl;
    }
    else
    {
        cout << "Contains less than two spaces!" << endl;
    }
}
else
{
    cout << "Contains no spaces!" << endl;
}using name spaces:

include <iostream>
#include <string>
using namespace std;

#include <boost/regex.hpp>

int main ()
{
    boost::regex fullname_regex ("[A–Z]+[a–z]*, [A–Z][a–z]*");

    string name;
    cout << "Enter you full name: " << flush;

    getline (cin, name);
    if (! regex_match (name, fullname_regex))
    {
        cout << "Error: name not entered correctly" << endl;
    }

    return 0;
}

Vector of string: