#include<iostream>
using namespace std;
char DFA[3][3]={
{'b','a','c'},
{'c','a','b'},
{'b','a','b'}
};
int testDFA(char , int );
void main()
{
cout<<"the regExpression is (a|b)*ab"<<endl;
cout<<"please input your string number"<<endl;
int num=0;
cin>>num;
char *a;
a = new char[num];
cout<<"string"<<endl;
for(int i=0;i<num;i++)
{
cin>>a[i];
}
int c= 0 ,n= 1;
for(int q=0;q< num; q++)
cout<<a[q];
cout<<endl;
for(int j=0;j<num; j++)
{
n=testDFA(a[j],c);
cout<<"State is from "<<c<<" to "<<n<<endl;
c =n;
if(c==4)
{
cout<<"the string does not meet the needs."<<endl;
break;
}
}
if(c == 2)
{
cout<<"the string meet the needs.";
}
else
{
cout<<"the string does not meet the needs."<<endl;
}
}
int testDFA(char x, int cur)
{
for(int state=0; state< 4; state++)
{
if(DFA[cur][state] ==x)
{
return state;
}
}
return 4;
}