2

我制作了一个 DFA 模拟器。

如果节点 0 是初始状态,节点 3 是最终状态,如权重图实现。

char CurrentStateAccept[stateN][alphabetN][alphabetN] = { {"01"} , {"0"} , {"0","1"} ,{} }; // 0, 1, 2, 3
int NextState[stateN][alphabetN] = {{1},{2},{0,3},{}};

我想得到 1, 1, 2, 0

  • 节点 0,接受(0 或 1)-> 节点 1
  • 节点 1,接受(0)-> 节点 2
  • 节点 2,接受(0)-> 节点 0
  • 节点 2,接受(1)-> 节点 3
  • 节点 3 是 dfa 的最终状态。

所以我想获取 char CurrentStateAccept[每个状态] 的元素号以使用“for loop”ex)

for(i=0; i<currentState element num; i++)
{
   for(j=0; j<end of alphabet of each element; j++)
   {
       there is acceptable state? or not?
   }
}

我怎样才能进入C?

4

1 回答 1

3

你的意思是这样的

sizeof(array)/sizeof(type of array);
于 2012-09-22T16:29:04.850 回答