#include
#include
void CreateDFA();
int StateMoveInDFA(int,char);
char Letters[10];
int NoOfInputLetter,NoOfStates,NoOfFinalState;
int FinalStates[5];
int DFA[10][10];
void main()
{
int s,i,Accepted;
char Line[10];
CreateDFA();
do
{
s=0;
i=0;
Accepted= 0;
printf("\n\nEnter Input String.. ");
scanf("%s",Line);
while(Line[i]!='\0')
if((s=StateMoveInDFA(s,Line[i++]))<0 p="">break;
for(i=0 ;iif(FinalStates[i] ==s )
Accepted= 1;
(Accepted)?printf("\nInputted String is Valid...") : printf("\nInputed String is Not Valid...");
getch();
printf("\n\nDo you want to continue..??(y/n)");
}
while(getch()=='y' || getch()=='Y');
}
void CreateDFA()
{
int i,j;
char c;
printf("Enter the no. of states.. ");
scanf("%d",&NoOfStates);
printf("Enter the no. of input letters.. ");
scanf("%d",&NoOfInputLetter);
printf("Enter the no. of final states.. ");
scanf("%d",&NoOfFinalState);
for(i=0;iprintf("Final state %d : ",i+1);
scanf("%d",&FinalStates[i]);
}
for(i=0;iprintf("\nInput Letter %d :",i+1);
printf("%c",Letters[i]=getch());
}
printf("\nEnter the State Movements In DFA...\n");
for(i=0;ifor(j=0;jprintf("Move(%d,%c) : ",i,Letters[j]);
scanf("%d",&DFA[i][j]);
}
}
}
int StateMoveInDFA(int s,char c)
{
int j;
for(j=0;jif(c==Letters[j])
return(DFA[s][j]);
return -1;
} 0>
#include
void CreateDFA();
int StateMoveInDFA(int,char);
char Letters[10];
int NoOfInputLetter,NoOfStates,NoOfFinalState;
int FinalStates[5];
int DFA[10][10];
void main()
{
int s,i,Accepted;
char Line[10];
CreateDFA();
do
{
s=0;
i=0;
Accepted= 0;
printf("\n\nEnter Input String.. ");
scanf("%s",Line);
while(Line[i]!='\0')
if((s=StateMoveInDFA(s,Line[i++]))<0 p="">break;
for(i=0 ;i
Accepted= 1;
(Accepted)?printf("\nInputted String is Valid...") : printf("\nInputed String is Not Valid...");
getch();
printf("\n\nDo you want to continue..??(y/n)");
}
while(getch()=='y' || getch()=='Y');
}
void CreateDFA()
{
int i,j;
char c;
printf("Enter the no. of states.. ");
scanf("%d",&NoOfStates);
printf("Enter the no. of input letters.. ");
scanf("%d",&NoOfInputLetter);
printf("Enter the no. of final states.. ");
scanf("%d",&NoOfFinalState);
for(i=0;i
scanf("%d",&FinalStates[i]);
}
for(i=0;i
printf("%c",Letters[i]=getch());
}
printf("\nEnter the State Movements In DFA...\n");
for(i=0;i
scanf("%d",&DFA[i][j]);
}
}
}
int StateMoveInDFA(int s,char c)
{
int j;
for(j=0;j
return(DFA[s][j]);
return -1;
}
No comments:
Post a Comment