Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #include "afnd.h"
  6. #include "minimize.h"
  7.  
  8. int main(int argc, char ** argv)
  9. {
  10.  
  11. AFND * p_afnd;
  12. int *accesibles;
  13. int i, numEstados, numAccesibles;
  14.  
  15. p_afnd= AFNDNuevo("afnd", 8, 2);
  16.  
  17. AFNDInsertaSimbolo(p_afnd,"0");
  18. AFNDInsertaSimbolo(p_afnd,"1");
  19.  
  20. AFNDInsertaEstado(p_afnd, "A",INICIAL);
  21. AFNDInsertaEstado(p_afnd, "B", NORMAL);
  22. AFNDInsertaEstado(p_afnd, "C", FINAL);
  23. AFNDInsertaEstado(p_afnd, "D", NORMAL);
  24. AFNDInsertaEstado(p_afnd, "E", NORMAL);
  25. AFNDInsertaEstado(p_afnd, "F", NORMAL);
  26. AFNDInsertaEstado(p_afnd, "G", NORMAL);
  27. AFNDInsertaEstado(p_afnd, "H", NORMAL);
  28.  
  29. AFNDInsertaTransicion(p_afnd, "A", "0", "B");
  30. AFNDInsertaTransicion(p_afnd, "A", "1", "F");
  31. AFNDInsertaTransicion(p_afnd, "B", "0", "G");
  32. AFNDInsertaTransicion(p_afnd, "B", "1", "C");
  33. AFNDInsertaTransicion(p_afnd, "C", "0", "A");
  34. AFNDInsertaTransicion(p_afnd, "C", "1", "C");
  35.  
  36. AFNDInsertaTransicion(p_afnd, "D", "0", "C");
  37. AFNDInsertaTransicion(p_afnd, "D", "1", "G");
  38. AFNDInsertaTransicion(p_afnd, "E", "0", "H");
  39. AFNDInsertaTransicion(p_afnd, "E", "1", "F");
  40. AFNDInsertaTransicion(p_afnd, "F", "0", "C");
  41. AFNDInsertaTransicion(p_afnd, "F", "1", "G");
  42. AFNDInsertaTransicion(p_afnd, "G", "0", "G");
  43. AFNDInsertaTransicion(p_afnd, "G", "1", "E");
  44. AFNDInsertaTransicion(p_afnd, "H", "0", "G");
  45. AFNDInsertaTransicion(p_afnd, "H", "1", "C");
  46.  
  47.  
  48. numEstados = AFNDNumEstados(p_afnd);
  49.  
  50. /* Obtenemos una lista que contenga unicamente los estados accesibles */
  51. accesibles = estadosAccesibles(p_afnd);
  52. for (i=0, numAccesibles=0; i<numEstados; i++){
  53. if (accesibles[i] == 1){
  54. accesibles[numAccesibles] = i;
  55. numAccesibles++;
  56. }
  57. }
  58.  
  59. estadosDistinguibles(p_afnd, accesibles, numAccesibles);
  60.  
  61. free(accesibles);
  62. AFNDElimina(p_afnd);
  63.  
  64. return 0;
  65.  
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement