Task 5 in C
Task 5 in C
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
typedef struct {
int state;
bool epsilon;
int transitions[MAX_STATES];
int numTransitions;
} State;
// If the transition is an ε transition and the next state hasn't been visited
// Function to compute the set of states reachable from a given set of states on a given input symbol
void computeStateSet(State nfa[], int states[], int numStates, int symbol, int resultSet[])
{
int index = 0;
// If the transition matches the input symbol, add the next state to the result set
resultSet[index++] = nextState;
int main() {
State nfa[MAX_STATES];
int dfaStates[MAX_STATES][MAX_ALPHABET] = { 0 };
int dfaNumStates = 0;
scanf("%d", &numStates);
scanf("%d", &numSymbols);
nfa[i].state = i;
printf("Is State %d an epsilon state? (0 for no, 1 for yes): ", i);
scanf("%d", &nfa[i].epsilon);
scanf("%d", &nfa[i].numTransitions);
scanf("%d", &nfa[i].transitions[j]);
printf("\n");
int closure[MAX_STATES] = { 0 };
int symbol = j;
// Compute the set of states reachable from the ε-closure of the current state on the input symbol
int resultSet[MAX_STATES] = { 0 };
// Add the resulting state set to the DFA states if it is not empty and not already in the DFA states
if (resultSet[0] != 0)
{
newState = false;
break;
if (newState)
printf("\nDFA States:\n");
printf("\n");
return 0;