Advertisement
Guest User

5654

a guest
Mar 22nd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6.  
  7. class Automat
  8. {
  9.         char * alfabet;
  10.         int nr_stari;
  11.         int * stari;
  12.  
  13.         int stare_initiala;
  14.         int nr_stari_finale;
  15.         int * stari_finale;
  16.  
  17.         int nr_much;
  18.         char ***a; //structura automatului
  19.     public:
  20.  
  21.         Automat();
  22.         void citire();
  23.         void initializare_matrice();
  24.  
  25. };
  26.  
  27. Automat::Automat()
  28. {
  29.     alfabet=NULL;
  30.     stari=NULL;
  31.     stari_finale=NULL;
  32.     a=NULL;
  33.  
  34.     nr_stari=0;
  35.     stare_initiala=0;
  36.     nr_stari_finale=0;
  37.     nr_much=0;
  38.  
  39. }
  40.  
  41. void Automat::initializare_matrice()
  42. {
  43.     cout<<nr_stari<<' ';
  44.      int lung=strlen(alfabet);
  45.      cout<<lung;
  46.      for(int i=0;i<nr_stari;i++) //pe linii sunt starile
  47.         for(int j=0;j<lung;j++)
  48.         {
  49.             cout<<9; a[i][j][0]='\0';  //fiecare element e un string, initial fiind vid
  50.             }//pe coloane sunt simbolurile din alfabet
  51.  
  52. }
  53.  
  54. int caut(void *v,int n,const void * x,int dim)
  55. {
  56.     char * p;
  57.     p=(char *) v;
  58.  
  59.     for(int i=0;i<n;i++)
  60.         if(memcmp(p+i*dim,x,dim)==0)
  61.                return 1;
  62.     return 0;
  63. }
  64.  
  65. void Automat::citire()
  66. {
  67.  
  68.   /*  ifstream fin("date_automat.in");
  69.     char s[100];
  70.     fin>>s;
  71.     alfabet=new char[strlen(s)+1];
  72.     strcpy(alfabet,s);
  73.     cout<<alfabet;
  74.  
  75.     fin>>nr_stari;
  76.     stari=new int[nr_stari];
  77.     for(int i=0;i<nr_stari;i++)
  78.         fin>>stari[i];
  79.     //cout<<nr_stari;
  80. */
  81.     nr_stari=3;
  82.     alfabet="ab";
  83.     initializare_matrice();
  84.     cout<<1;
  85.     /*fin>>stare_initiala;
  86.  
  87.     fin>>nr_stari_finale;
  88.     stari_finale=new int[nr_stari_finale];
  89.     for(int i=0;i<nr_stari_finale;i++)
  90.         fin>>stari_finale[i];
  91.  
  92.     fin>>nr_much;
  93.     for(int i=0;i<nr_much;i++)
  94.     {
  95.         int x,y,lit;
  96.         fin>>x>>y>>lit;
  97.  
  98.  
  99.     }
  100.  
  101.     fin.close();
  102. */
  103. }
  104. int main()
  105. {
  106.     Automat A;
  107.     A.citire();
  108.     return 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement