Answer:
// See attachment for full source code and output
// Program was implemented using C++ Programming Language
// Comments are used for explanatory purpose
#include<iostream>
using namespace std;
int main()
{
int n = 0; // Declare and initialise an integer variable n to 0
string prev ="xxxxx", current, next; // Declare string variables prev, current and next.
// At the same time initialise variable string to xxxxx
cin>>current; // Accept input for variable current
//If current is not equal to prev, the following statement in between the loop will be executed
// Else the program is terminated
while(current!=prev)
{
cin>>next; // accept input for variable next
if(prev != current && current != next)
{
n++; // Increment n by 1
}
prev = current; //store the value of current in previous
current = next; // store the value of next in current
cout<<prev<<endl; // Print previous string
cout<<current<<endl; // Print current string
cout<<next<<endl; // Print next string
}
return 0;
}