English 中文(简体)
实施一部法典,模拟在C++中确定为零的单质。
原标题:Implementing a code to simulate a finite automaton nondeterministic in c++

我在为汽车理论进行分配时,必须确定一个词是否为最终的自治州接受过渡职能。

我有这份投入文件:

6 8 0 2
2
5
0 0 a
0 1 a
1 1 b
1 2 c
1 3 c
3 4 d
4 4 d
4 5 d
3
aaabcccc
aabbbbcdc
acdddddd

投入开始时是4个分类,第一个是自治州的数量,下一个是自治州的过渡数量,第三个是初步状态,然后是最后各州的数量。 之后是最后各州(例如,最后各州为2和5个)。

然后是N项目(N是过渡的数量),每个项目有2个分类和特性,即I、J和C,代表过渡的各州,即从具有特征C的I级过渡到J级。

该方案的产出应当是:

Case #2:
aaabcccc Rejected
aabbbbcdc Rejected
acdddddd Accepted

它应当说,“强权”是接受还是拒绝的。 迄今为止,我只用投入把工作编码。

www.un.org/spanish/ecosoc 我不知道如何最方便地代表自治州。 我是否只是使用阵列? 我对阵列有什么逻辑? 在事先不知情的情况下,是否有办法这样做? 我是否需要一个数据结构来代表自动化吗? 我对这项任务毫不犹豫,并祝愿某些想法、一些假装或想法这样做。 守则是否使用另一种语言? 我不想解决问题,因为我想做我的任务,但如果我能利用一些帮助的话。

最佳回答

我认为,如果从<代码>i state to j state through c,则通过<代码>c,通过<代码>c向最后状态的列册<代码>fs[m],在m为初始状态最后状态的序号和立体<0<代码>上下的过渡,则可以有一份地图<代码>>。

下面是具有这种特性的类别:

class Automata
{
public:
    Automata(int start) : s0(start)
    {}

    void add_transition(int i, int j, char c) {
        //...
    }

    void add_final_state(int i) {
        //...
    }

    bool validate_string(const std::string& str) {
        //...
    }
private:
    std::map<std::pair<int, char>, int> tr; // transitions
    std::vector<int> fs; // final states
    int s0; // initial state
};
问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签