Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. void main()
  4. {
  5. char str[100];
  6. int table[3][2]={{1,0},{1,2},{2,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==2&&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