用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;
}
}
。。。
}
写得太粗了,呵呵。
相关问答:
编译普通的c没问题啊,但编译javah生成的就报错:
gcc -O0 -g3 -Wall -c -fmessage-length=0 -oHelloWorld.o ..\HelloWorld.c
gcc -otest.exe HelloWorld.o
d:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../. ......
为什么C写的DLL文件C、PB能调用VB不能调用?
VB里为什么有的DLL直接通过引用可以使用?有的需要通过declare申明外部函数?这些DLL有什么差别?
1、为什么PB能通过DECLARE声明而VB不行?
2、如果这个dll中的 ......
C\C++如何计算函数的导数,本人新手,想写个程序,但是不知道如何下手,还望高手指点一二,谢过。
这个……
跟函数的具体形式有关吧,难道你想编出个“万能”的求导函数?
俺上学时想过自动推导公式,后来 ......
问一下:
#include <stdio.h>
int main()
{
char x, y, z;
int i;
int a[16];
for(i=0; i<=16; i++)
{
a[i] = 0;
......
'\108'作为字符常量对不对?
转义字符'\ddd'表示3位8进制所代表的字符。 但是108不是正确的8进制表示方法,因此应该是错误的。
但是char a='\108'; 为什么编译不出错呢?
\108 没超过 ......