void run_state(state)
{
switch(state->next)
{
case state1:
{
if (do_state1() == -1)
{
state->next = state1;
}
else
{
state->next = state2;
}
run_state(state);
break;
}
case state2:
{
do_state2();
state->next = state3;
run_state(state);
break;
}
case state3:
{
do_state3();
state->next = state4;
run_state(state);
break;
}
case state4:
{
do_state4(state);
state->next = state5;
run_state(state);
break;
}
case state5;
{
state->next = state5;
break;
}
}
}
c语言递归方式实现状态机
最新推荐文章于 2021-03-14 23:26:00 发布