Created
December 19, 2019 22:13
-
-
Save lascar-pacagi/e2ac6243986672d9c85a839f26eadc52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<vector<int>> dfa | |
{ | |
// a b | |
/*0*/ { 1, 0 }, | |
/*1*/ { 1, 2 }, | |
/*2*/ { 3, 0 }, | |
/*3*/ { 1, 2 }, | |
}; | |
int state = 0; | |
char c; | |
while (cin >> c) { | |
state = dfa[state][c - 'a']; | |
} | |
cout << "Input is " << (state == 3 ? "" : "not ") << "in the language\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment