// Example Finite State Machine (FSM) program example
#include <stdio.h>
// When turning in your code for HW 3, only include from here...
//----------------- START CUT HERE -----------------------------
// My states
typedef enum states {STATE_INIT, STATE_A, STATE_B, STATE_EXIT} State;
// My transitiion functions
State computeTransitionFromStateA(int value) {
State returnState = STATE_A;
if (value==1) {
returnState = STATE_B;
}
return(returnState);
State computeTransitionFromStateB(int value) {
State returnState = STATE_B;
if (value==2) {
returnState = STATE_A;
} else if (value==(-1)) {
returnState = STATE_EXIT;
// My finite state machine
State finiteStateMachine(int num)
{
static State systemState = STATE_INIT;
switch (systemState) {
case STATE_INIT:
systemState = STATE_A;
break;
gcc