有会员反应不会写这类题目
故将我写的原始程式与注解公布
欢迎大家参予这次的活动
只要能符合八后棋的规则
都是可以加入比赛的
Option Explicit
Dim xy(1 To 8, 1 To 8) As String
Dim i As Integer, j As Integer, k As Integer, cnt As Integer, rule As Integer, tot As Integer
Dim g As Integer, h As Integer
Dim tmpx As Integer, tmpy As Integer
Private Sub Check1_Click() '开关座标
Text1.Visible = Not Text1.Visible
Text3.Visible = Not Text3.Visible
End Sub
Private Sub Command1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) '座标效果
With Command1(Index)
Text1.Top = .Top + 220: Text1.Left = .Left - 3500
Text3.Top = .Top - 3500: Text3.Left = .Left + 220
End With
End Sub
Private Sub Command1_Click(Index As Integer) '单局八后棋
judgequeen Index
If cnt Mod 8 = 0 And rule = 0 Then
Text2.Text = Text2.Text & "恭禧完成一组八后棋!!": cnt = 0
ElseIf cnt Mod 8 = 4 And rule = 0 Then
Text2.Text = Text2.Text & " 加油 ^^ 剩 " & 8 - cnt & Chr(13) & Chr(10)
ElseIf cnt Mod 8 <> 0 And rule = 0 Then
Text2.Text = Text2.Text & " 剩 " & 8 - cnt & Chr(13) & Chr(10)
End If
End Sub
Private Sub Command2_Click() '列出组合清单
Dim i1 As Integer, j1 As Integer
Dim startime As Date
startime = Now
clsxyicon 1, 1
Text2.Text = "": Text2.Text = "开始时间 " & Format(Now, "hh:mm:ss") & Chr(13) & Chr(10)
Text2.Text = Text2.Text & "-------------------------------------------------" & Chr(13) & Chr(10)
tot = 0
For i = 1 To 8 '四面的组合都是一样,只求一面即可
tmpx = i: tmpy = 1: recxy
For i1 = 1 To 8 '二元树规范取得八后
For j1 = 1 To 8
tmpx = i1: tmpy = j1: recxy
If rule = 0 Then '取得每一Y轴所有皇后的位置
doxyicon
If i1 = 8 Then '当X轴在8且又可放皇后则列出组合
calarrQ
If Check2.Value = 1 Then
Dim yn As Integer
yn = MsgBox("第 " & tot & " 组,是否继续!!", vbYesNo)
..
访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容