形式语言和自动机
#include#include using namespace std; int st[4][2] = { {2,1},{3,0},{0,3},{1,2} };//״̬��ʾ int main() { int cnt = 3; while (cnt--) { string s; cin >> s; bool flag = true; for (auto x : s) //���� if (x != '0' && x != '1') { cout << "�ַ����е��ַ�����������ż���" << endl; flag = false; break; } if (!flag) continue; int q = 0; //״̬ for (auto x : s) { int choice = int(x) - 48; q = st[q][choice]; } if (q == 0)//�ж�����Ƿ��ȥ cout << "�ַ������Ա������Զ�������" << endl; else cout << "�ַ��������Ա������Զ�������" << endl; } return 0; }



