Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. //Koen Buitenhuis   s4069471
  2. //Bas de Leeuw      s4064267
  3.  
  4. #include <iostream>
  5. #include <cstdlib>
  6. #include <cstring>
  7. using namespace std ;
  8.  
  9. enum S {q0, q1, q2, q3, q4} ;
  10. const int ltslength = 5, lblamount = 4 ;
  11. const string Labels [lblamount] = {"d","t","c","_"} ;
  12. const string LTS [ltslength][ltslength] =  {
  13.                             {"d","d","","",""},
  14.                             {"","","t","d",""},
  15.                             {"_","","","",""},
  16.                             {"","t","","","c"},
  17.                             {"_","","","",""}
  18.                             } ;
  19.  
  20.  
  21. bool lts_is_deterministic()
  22. {
  23.     int xcoord = 0, ycoord = 0, count = 0, count2 = 0 ;
  24.     string labels [99] ;
  25.     while (ycoord < ltslength)
  26.     {
  27.         while (xcoord < ltslength)
  28.         {
  29.             while (count <= count2)
  30.             {
  31.                 if (LTS [ycoord][xcoord] == labels [count])
  32.                     return false ;
  33.                 else
  34.                 {
  35.                     if (count == count2)
  36.                     {
  37.                         count2++ ;
  38.                         labels [count] = LTS [ycoord][xcoord] ;
  39.                         count = 0 ;
  40.                     }
  41.                     else count++ ;
  42.                 }
  43.             xcoord++ ;
  44.             }
  45.         for (int i = 0; i <= count2; i++)
  46.             labels [i] = "" ;
  47.         ycoord++ ;
  48.         xcoord = 0 ;
  49.         }
  50.     return true ;
  51.     }
  52. }
  53.  
  54. bool trace_is_valid (S s, string trace[], int l)
  55. {
  56.     int counter = 0, count2 = 0, state ;
  57.     cout << "In welke state wil je beginnen?" ;
  58.     cin >> state ;
  59.     while (count2 < ltslength)
  60.     {
  61.         if (trace[counter] == LTS [state] [count2])
  62.         {
  63.             state = count2 ;
  64.             counter++ ;
  65.             if (counter == l + 1)
  66.                 return true ;
  67.             count2 = 0 ;
  68.         }
  69.         else count2++ ;
  70.     }
  71.     if (counter == l + 1)
  72.         return true ;
  73.     else return false ;
  74. }
  75.  
  76. void validtracetest ()
  77. {
  78.     const int tracelength = 99 ;
  79.     int tracelengte ;
  80.     string trace [tracelength] ;
  81.     cout << "Voer in hoeveel opdrachten de trace bevat" ;
  82.     cin >> tracelengte ;
  83.     cout << "Voer de gewenste trace in: " ;
  84.     for (int i = 0; i < tracelengte; i++)
  85.         cin >> trace [i] ;
  86.     if (trace_is_valid(q0,trace,tracelengte))
  87.         cout << "Klopt" ;
  88.     else cout << "Klopt niet" ;
  89.     ;
  90. }
  91.  
  92. int main ()
  93. {
  94.     if (lts_is_deterministic)
  95.         cout << "klopt" ;
  96.     else
  97.         cout << "klopt nie" ;
  98. //    validtracetest () ;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement