用C编写state machine
有4个state 的state machine
x=0, y=0 state0
x=1, y=0 state1
x=0, y=1 state2
x=1, y=1 state3
想请教各位大侠 是不是可以这样编写state machine?
大家工作中一般都用什么方法编写state machine呢?
int main()
{
。。。
while (1)
{
while (x=0, y=0)
{
state0;
}
while (x=0, y=1)
{
state1;
}
while (x=1, y=0)
{
state2;
}
while (x=1, y=1)
{
state3;
}
}
。。。
}
写得太粗了,呵呵。
相关问答:
#include <stdio.h>
#include <graphics.h>
void main()
{
int x0,y0,x1,y1,driver,mode,i;
driver=VGA;
mode=VGAHI;
initgraph(&driver,&mode,&qu ......
C\C++如何计算函数的导数,本人新手,想写个程序,但是不知道如何下手,还望高手指点一二,谢过。
这个……
跟函数的具体形式有关吧,难道你想编出个“万能”的求导函数?
俺上学时想过自动推导公式,后来 ......
'\108'作为字符常量对不对?
转义字符'\ddd'表示3位8进制所代表的字符。 但是108不是正确的8进制表示方法,因此应该是错误的。
但是char a='\108'; 为什么编译不出错呢?
\108 没超过 ......
如题,请知道的高手指点一下,THANKS
PHP函数都是用C实现的~
反其道而行之~
HOHO,关键是,自已再去实现这个功能累啊,PHP有现成的就直接调用好了,
顶起,有高手点解一下,或者是我直接将PHP 源码中的 .c ......
#include <stdio.h>
main()
{
int a,b,sum;
a=1;b=2;
sum=a+b;
printf("sum is %d\n");
}
结果是:2367460
为什么?
printf("sum is %d\n", ......