Answer:
The code is given below. Follow the question and the code definitions for better understanding.
Step-by-step explanation:
#include<iostream>
#include<string>
using namespace std;
int main(){
string pastWord="";
string currentWord,nextWord;
int n,t;
int singleton=0;
int consecutive=0;
cout<<"Enter words. ('xxxxx' to exit):\\";
cin>>nextWord;
do{
currentWord=nextWord;
cin>>nextWord;
if ( (currentWord!=pastWord)&&(currentWord!=nextWord) )
singleton++;
else if((currentWord==pastWord)&&(currentWord!=nextWord))
consecutive++;
pastWord=currentWord;
}while(nextWord!="xxxxx");
n=singleton;
t=consecutive;
cout<<"There were "<<n<<" singletons and "<<t<<" consecutive repetitions.";
cin.get();
return 0;
}