Recognize Strings Cs
Recognize Strings Cs
Objective
To recognize whether the given input strings belong to the regular expressions a*, a*b+, or abb.
Algorithm
2. For a*b+: Check if the string starts with zero or more 'a' followed by one or more 'b'.
Program (C)
Copy code
#include <stdio.h>
#include <string.h>
return 1;
int i = 0;
int main() {
char input[100];
scanf("%s", input);
if (match_a_star(input))
printf("Matches a*\n");
else if (match_a_star_b_plus(input))
printf("Matches a*b+\n");
else if (match_abb(input))
printf("Matches abb\n");
else
printf("No match\n");
return 0;
Sample Output
plaintext
Copy code
Matches abb