Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<string.h>
  3. void main()
  4. {
  5. char str[100];
  6. int table[4][2]={{3,1},{2,0},{1,3},{0,2}};
  7. int state=0,check=1,i;
  8. printf("Enter the input string:");
  9. gets(str);
  10. for(i=0;i<strlen(str);i++)
  11. {
  12. if(str[i]=='0')
  13. state=table[state][0];
  14. else if(str[i]=='1')
  15. state=table[state][1];
  16. else
  17. check=0;
  18. }
  19. if(state==1&&check==1)
  20. printf("The String is accepted.");
  21. else
  22. printf("\nThe String is not accepted.");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement