-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRE.cpp
More file actions
47 lines (46 loc) · 1.03 KB
/
RE.cpp
File metadata and controls
47 lines (46 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//C Program for implementing DFA of Regular Expression
//(a+aa*b)*
#include<stdio.h>
#include<string.h>
int main()
{
char input[100];
int status_a=0,status_b=0;
printf("Enter the string \n");
scanf("%s",input);
int len=strlen(input),i;
for(i=0;i<len;i++)
{
if(input[i]!='a' && input[i]!='b')
{
printf("You Entered wrong input\n");
break;
} //abb
else
{
if(input[i]=='a')
{
status_a=1;
status_b=0;
}
else
{
if(status_b==1 || status_a==0)
{
printf("String is not accepted \n");
break;
}
else
{
status_b=1;
status_a=0;
}
}
}
if(i==len-1)
{
printf("String is Accepted \n");
}
}
return 0;
}