布尔系统(用于C ++ / C#/ JAVA) [英] Boolean system ( for C++/ C#/java)

查看:107
本文介绍了布尔系统(用于C ++ / C#/ JAVA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何编程解决这种类型的系统:

How can I programatically resolve this type of system :

A = !B
B = !C
D = !B
E = !A
E = !B

这样我就可以通过替换获得 A = C = D(3) E = B(2) 。我只需要2组的数量。如果这是不可能得到2组,我显示错误消息。

so I can get by substituting A = C = D (3) and E = B (2). I only need the number of the 2 groups. If it's not possible to get 2 groups, I display an error message.

推荐答案

在的情况下,这是不关闭,一个傻瓜,从我的<一个href="http://stackoverflow.com/questions/6000632/whats-the-approach-to-solving-this-kind-of-logic-problem/6000708#6000708">answer在previous问题:

In case, this is not closed as a dupe, from my answer in your previous question:

要解决的形式方程

X <子> 1 =不是X <子> 3

X1 = NOT X 3

X <子> 5 =不是X 2

X5 = NOT X 2

形成具有节点的图形为X <子>我和连接X <子>我和X <子>Ĵ当且仅当方程x <子>我 =不是X <子>Ĵ出现。

Form a graph with nodes as Xi and connecting Xi and X j iff the equation Xi = NOT X j appears.

现在使用广度优先搜索尝试2色图。

Now try to 2-colour the graph using Breadth First Search.

这篇关于布尔系统(用于C ++ / C#/ JAVA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆