注册 登录
编程论坛 新人交流区

[求助]盗窃犯问题?

fengfei0210 发布于 2007-10-17 07:36, 497 次点击
盗窃犯问题:张某被盗,公安局派出5个侦察员去调查.研究案情时,第一个侦察员说"A与B至少有一人是盗窃犯";第二个侦察员说"B与C至少有一人是盗窃犯";第三个侦察员说"C与D至少有一人是盗窃犯";第四个侦察员说"A与C中至少有一人不是盗窃犯";第五个侦察员说"B与D至少有一人不是盗窃犯".如果这些侦察员的话都是可靠的,编程求谁是真正的盗窃犯.
程序如下:Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim c1 As Integer, c2 As Integer, c3 As Integer, c4 As Integer, c5 As Integer
For a = 0 To 1
For b = 0 To 1
For c = 0 To 1
For d = 0 To 1
c1 = a Or b
c2 = b Or c
c3 = c Or d
c4 = Not a Or Not c
c5 = Not b Or Not d
If (c1 And c2 And c3 And c4 And c5) Then
If (a = 1) Then
Text1.Text = "是"
Else
Text1.Text = "否"
If (b = 1) Then
Text2.Text = "是"
Else
Text2.Text = "否"
If (c = 1) Then
Text3.Text = "是"
Else
Text3.Text = "否"
If (d = 1) Then
Text4.Text = "是"
Else
Text4.Text = "否"
End If
End If
Next d
Next c
Next b
Next a
End Sub
但是运行程序的时候,出现"编译错误:next 没有 for"的提示,这是为什么?
3 回复
#2
happiness5202007-10-17 08:37

刚刚开始学VB~~不知道怎么搞~~我只知道

c1 And c2 And c3 And c4 And c5 C1 ~ C5是警察~

For a = 0 To 1
For b = 0 To 1
For c = 0 To 1
For d = 0 To 1

这里为什么要进行循环~~??

还有后面的就比较复杂~~看起来有点乱了~~

#3
千里冰封2007-10-17 09:38
BC
#4
xhxlmm2007-10-17 09:44

这不是无限循环吗??

1