#include using namespace std; int main() { const int SIZE = 25; char e[SIZE]; int condition; char again; do { cout << "Please enter a string of 1 and 0: "; cin >> e; //Program will only consider 1 and 0. condition = 0; for(int i = 0; i < SIZE; i++) { if(e[i] == '1') { if(condition == 0) //If state zero, input one moves to state one { condition = 1; } else if(condition == 1) //If state one, input one moves to state two { condition = 2; } else if(condition == 3) //If state three, input one moves to state four { condition = 4; cout << "String is accepted\n"; //at state four, string is accepted and program terminates break; } } else { if(condition == 0) //If state zero, input zero keeps at state zero { condition = 0; } else if(condition == 1) //If state one, input zero moves to state zero { condition = 0; } else if(condition == 2) //If state two, input zero moves to state three { condition = 3; } else if(condition == 3) //If state three, input zero moves to state zero { condition = 0; } } } cout << endl; cout << "Would you like to enter another string: "; cin >> again; }while(again == 'y' || again == 'Y'); return 0; }