[text] chuieif

Viewer

  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<strings.h>
  4. void main() {
  5.    int table[2][2],i,j,l,status=0,success;
  6.    char input[100];
  7.    printf("To implementing DFA of language (a+aa*b)* Enter Input String:”);
  8.    table[0][0]=1;
  9.    table[0][1]=-1;
  10.    table[1][0]=1;
  11.    table[1][1]=0;
  12.    scanf("%s",input);
  13.    l=strlen(input);
  14.    for (i=0;i<l;i++) {
  15.       if(input[i]!='a'&&input[i]!='b'&& input[i]!='c') {
  16.          printf("The entered Value is wrong");
  17.          getch();
  18.          exit(0);
  19.       }
  20.       if(input[i]=='a')
  21.       status=table[status][0]; else
  22.       status=table[status][1];
  23.       if(status==-1) {
  24.          printf("String not Accepted");
  25.          break;
  26.       }
  27.    }
  28.    if(i==l)
  29.       printf("String Accepted");
  30.    getch();
  31. }

Editor

You can edit this paste and save as new:


File Description
  • chuieif
  • Paste Code
  • 26 Apr-2024
  • 768 Bytes
You can Share it: