You are on page 1of 2

#include <iostream>

#include <vector>
#include <fstream>
using namespace std;
class pereche
{int first, third;
char second;
public:
pereche(int a,char b,int c)
{first=a;
second=b;
third=c;
}
void afisare();
friend class AFN;
};
void pereche::afisare()
{cout<<first<<second<<third;
}
class AFN
{int q, f, *F;
vector <pereche> D;
public:
AFN(char *nume_fis)
{ifstream fin(nume_fis);
fin>>q>>f;
F=new int[f];
int i, k;
char j;
for(i=0;i<f;i++)
fin>>F[i];
while(fin>>i>>j>>k)
{pereche oc(i,j,k);
D.push_back(oc);
}
}
void afisare();
bool procesare(char *,int);
};
void AFN::afisare()
{for(int i=0;i<D.size();i++)
cout<<D[i].first<<D[i].second<<D[i].third<<endl;
}
bool AFN::procesare(char *cuv,int dim)
{vector <int> qc, qv;
qc.push_back(0);
int i, j, k;
for(i=0;i<dim;i++)
{char c=cuv[i];
for(j=0;j<qc.size();j++)
for(k=0;k<D.size();k++)
if(D[k].first==qc[j] && D[k].second==c)
qv.push_back(D[k].third);

qc=qv;
qv.erase(qv.begin(),qv.end());
}
for(i=0;i<f;i++)
for(j=0;j<qc.size();j++)
if(F[i]==qc[j])
return true;
return false;
}
int main()
{pereche a(1,'a',2);
a.afisare(); cout<<endl;
AFN A("intrare.txt");
A.afisare();
if(A.procesare("abb",3))
cout<<"acceptat";
else
cout<<"neacceptat";
}

You might also like