#include <iostream>
#include <vector>
using namespace std;
int main() {
vector <string> oneWordPhrase = {"hello", "my", "is", "bob", "oh", "hey", "jay", "oh"};
vector <string> twoWordPhrase;
vector <string> threeWordPhrase;
vector<string>::iterator it1;
vector<string>::iterator it2;
for(it1=oneWordPhrase.begin(); it1!=oneWordPhrase.end(); it1++)
{
if(it1+1 == oneWordPhrase.end())
break; /* if we reach the last element of the vector
get out of loop because we reached the end */
twoWordPhrase.push_back(*it1 + ' ' + *(it1+1));
}//gets each 2 consecutive words in the sentence
cout<<"two word---------------\n";
for(int i=0; i<twoWordPhrase.size(); i++)
cout<<'[' << twoWordPhrase[i] << ']' <<endl;
for(int i=0; i<twoWordPhrase.size()-1; i++)
{
it1=twoWordPhrase.begin()+i;
it2=oneWordPhrase.begin()+i+2;
if(it1==twoWordPhrase.end()-2)
break; //signal break but doesnt work
threeWordPhrase.push_back(*it1 + ' ' + *it2);
}
cout<<"3 word---------------\n";
for(int i=0; i<threeWordPhrase.size(); i++)
cout<<'[' << threeWordPhrase[i] << ']' <<endl;
return 0;
}