Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- void main()
- {
- char str[100];
- int table[3][2]={{1,0},{1,2},{2,2}};
- int state=0,check=1,i;
- printf("Enter the input string:");
- gets(str);
- for(i=0;i<strlen(str);i++)
- {
- if(str[i]=='0')
- state=table[state][0];
- else if(str[i]=='1')
- state=table[state][1];
- else
- check=0;
- }
- if(state==2&&check==1)
- printf("The String is accepted.");
- else
- printf("\nThe String is not accepted.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement