سلام به همه جوونای ایران عزیز اینم برنامه تبدیل که خواسته بودین
همیشه سربلند و آزاد باشید...
struct TLink
{
int linkNode;
int stringMax;
int string[5];
};
struct Node
{
int isFinalState;
int max_links;
TLink Link[5];
} NFA[5];
struct DLink
{
int meCilinLidhet;
int stringNo;
int node[5];
};
struct NodeD
{
int stringNode;
int isFinalState;
int max_links;
DLink Link[5];
} DFA[5];
int max_states;
int maxNode;
void NFA_input()
{
int i, j, k, f;
cout<<"\nHow MAny states does the NFA has =";
cin>>max_states;
for (i=0; i<max_states; i++)
{
cout<<"\nIs State q["<<i<<"] final State ? (yes=1, No=0)";
cin>>NFA[i].isFinalState;
cout<<"\nHow many transitions does this State have ?";
cin>>NFA[i].max_links;
for (j=0; j<NFA[i].max_links; j++)
{
cout<<"\nThe "<<j+1<<" transition is linking state q["<<i<<"] with
state =";
cin>>NFA[i].Link[j].linkNode;
cout<<"\nHow many strings make this transition=";
cin>>NFA[i].Link[j].stringMax;
for (k = 0; k < NFA[i].Link[j].stringMax; k++)
{
cout<<"\nEnter those strings=\n";
cout<<"delta["<<k+1<<"]= ";
cin>>NFA[i].Link[j].string[k];
}
}
}
}
void print_NFA()
{
int i, j, k ;
for (i=0; i<max_states; i++)
{
cout<<"\nState q["<<i<<"]";
for (j=0; j<NFA[i].max_links; j++)
{
cout<<"\n is linked with state q["<<NFA[i].Link[j].linkNode<<"]";
cout<<" with string";
for (k = 0; k < NFA[i].Link[j].stringMax; k++)
cout<<" " <<NFA[i].Link[j].string[k];
}
cout<<"\n";
}
cout<<"\nInitial State of the automata is:q[0]\n ";
cout<<"\nFinal States of the automata are: ";
for (i=0; i<max_states; i++)
{
if (NFA[i].isFinalState == 1)
cout<<"\n q["<<i<<"] \t";
}
}
int main()
{
clrscr();
char line[80]="-------------------------------------------------";
NFA_input();
cout<<"\nTranitions of the NFA are: \n";
cout<<line;
print_NFA();
cout<<"\n"<<line;
cin.get(); cin.ignore();
return 0;
}