#include<stdio.h>
#include<string.h>
int main()
{
char str[50],input[15],inpstate[15],outstate[15],state='A';
int i=0,j;
strcpy(input,"abcabcabcabc");
strcpy(inpstate,"AAABBBCCCDDD");
strcpy(outstate,"BAABCABADBAA");
printf("\nEnter the string:- ");
gets(str);
while(str[i]!='\0')
{
for(j=0;j<12;j++){
if(inpstate[j]==state && input[j]==str[i]){
state=outstate[j];
break;
}
}
if(j==12){
state='E';
break;
}
i++;
}
if(state=='D')
printf("\nValid String \n");
else
printf("\nInvalid String \n");
return 0;
}
No comments:
Post a Comment