Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Koen Buitenhuis s4069471
- //Bas de Leeuw s4064267
- #include <iostream>
- #include <cstdlib>
- #include <cstring>
- using namespace std ;
- enum S {q0, q1, q2, q3, q4} ;
- const int ltslength = 5, lblamount = 4 ;
- const string Labels [lblamount] = {"d","t","c","_"} ;
- const string LTS [ltslength][ltslength] = {
- {"d","d","","",""},
- {"","","t","d",""},
- {"_","","","",""},
- {"","t","","","c"},
- {"_","","","",""}
- } ;
- bool lts_is_deterministic()
- {
- int xcoord = 0, ycoord = 0, count = 0, count2 = 0 ;
- string labels [99] ;
- while (ycoord < ltslength)
- {
- while (xcoord < ltslength)
- {
- while (count <= count2)
- {
- if (LTS [ycoord][xcoord] == labels [count])
- return false ;
- else
- {
- if (count == count2)
- {
- count2++ ;
- labels [count] = LTS [ycoord][xcoord] ;
- count = 0 ;
- }
- else count++ ;
- }
- xcoord++ ;
- }
- for (int i = 0; i <= count2; i++)
- labels [i] = "" ;
- ycoord++ ;
- xcoord = 0 ;
- }
- return true ;
- }
- }
- bool trace_is_valid (S s, string trace[], int l)
- {
- int counter = 0, count2 = 0, state ;
- cout << "In welke state wil je beginnen?" ;
- cin >> state ;
- while (count2 < ltslength)
- {
- if (trace[counter] == LTS [state] [count2])
- {
- state = count2 ;
- counter++ ;
- if (counter == l + 1)
- return true ;
- count2 = 0 ;
- }
- else count2++ ;
- }
- if (counter == l + 1)
- return true ;
- else return false ;
- }
- void validtracetest ()
- {
- const int tracelength = 99 ;
- int tracelengte ;
- string trace [tracelength] ;
- cout << "Voer in hoeveel opdrachten de trace bevat" ;
- cin >> tracelengte ;
- cout << "Voer de gewenste trace in: " ;
- for (int i = 0; i < tracelengte; i++)
- cin >> trace [i] ;
- if (trace_is_valid(q0,trace,tracelengte))
- cout << "Klopt" ;
- else cout << "Klopt niet" ;
- ;
- }
- int main ()
- {
- if (lts_is_deterministic)
- cout << "klopt" ;
- else
- cout << "klopt nie" ;
- // validtracetest () ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement