Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim item As String = ListBox1.GetItemText(ListBox1.Items.Item(0))
- Dim n As Integer = 0, s As Integer = 0
- For a As Integer = 0 To item.Length - 1
- If item.Chars(a) <> " " Then
- n = Val(CStr(n) & item.Chars(a))
- Else
- For b As Integer = a + 1 To item.Length - 1
- s = Val(CStr(s) & item.Chars(b))
- a = item.Length
- Next
- End If
- Next
- Dim p(s + 1, s + 1) As Boolean
- For a As Integer = s To 0
- For b As Integer = 0 To s
- p(a, b) = False
- Next
- Next
- For a As Integer = s - 1 To 0
- For b As Integer = 0 To s - 1
- p(a, b) = False
- Next
- Next
- For a As Integer = 1 To n
- Dim sm As String = 0, x As String = 0, y As String = 0
- item = ListBox1.GetItemText(ListBox1.Items.Item(a))
- For b As Integer = 0 To item.Length - 1
- If item.Chars(b) <> " " Then
- sm = sm & item.Chars(b)
- Else
- For c As Integer = b + 1 To item.Length - 1
- If item.Chars(c) <> " " Then
- x = x & item.Chars(c)
- Else
- For d As Integer = c + 1 To item.Length - 1
- y = y & item.Chars(d)
- Next
- b = item.Length
- c = item.Length
- End If
- Next
- End If
- Next
- For b As Integer = 0 To Val(sm) - 1
- For c As Integer = 0 To Val(sm) - 1
- p(c + Val(x), b + Val(y)) = True
- Next
- Next
- Next
- For a As Integer = s - 1 To 0 Step -1
- Dim sc As String = ""
- For b As Integer = 0 To s - 1
- If p(b, a) = False Then
- sc = sc & "0"
- Else
- sc = sc & "1"
- End If
- Next
- ListBox1.Items.Add(sc)
- Next
- p(9, 7) = True
- For a As Integer = s - 1 To 0 Step -1
- For b As Integer = 0 To s - 1
- If p(b, a) = False Then
- Dim a1, b1 As Integer
- a1 = a
- b1 = b
- Dim a2, b2 As Integer
- a2 = a
- b2 = b
- Dim t1 As Integer = 0, t2 As Integer = 0
- If b + 1 < s Then
- If p(b + 1, a) = False Then
- t1 = t1 + 1
- Else
- a2 -= 1
- End If
- End If
- If b - 1 > 0 Then
- If p(b - 1, a) = False Then
- t2 -= 1
- End If
- End If
- If a + 1 < s Then
- If p(b, a + 1) = False Then
- t2 -= 1
- End If
- End If
- If a - 1 > 0 Then
- If p(b, a - 1) = False Then
- t1 = t1 + 1
- Else
- b2 += 1
- End If
- End If
- b = b2
- a = a2
- Dim p1, p2 As Integer
- p1 = 0
- p2 = 0
- p(b, a) = True
- Dim s1 As Integer = 1
- For c As Integer = 0 To t1
- ListBox2.Items.Add("@" & b + c & a - t1 + 1 + c & c)
- Try
- p(b + c, a - t1 + 1 + c) = True
- If c = 0 Then
- If b + c + 1 < s Then
- If p(b + c + 1, a - t1 + 1 + c) = False Then
- p1 += 1
- ElseIf p(b + c + 1, a - t1 + 1 + c) = True And p(b + c, a - t1 + 1 + c - 1) = False Then
- a2 -= 1
- End If
- End If
- If b + c - 1 > 0 Then
- If p(b + c - 1, a - t1 + 1 + c) = False Then
- p2 -= 1
- End If
- End If
- If a - t1 + 1 + c - 1 > 0 Then
- If p(b + c, a - t1 + 1 + c - 1) = False Then
- p1 += 1
- Else
- b2 += 1
- End If
- End If
- If c = t1 - 1 Then
- If a - t1 + 1 + c + 1 < s Then
- If p(b + c, a - t1 + c + 1 + 1) = False Then
- p2 -= 1
- End If
- End If
- t1 = p1
- t2 = p2
- p1 = 0
- p2 = 0
- c = -1
- a = a2
- b = b2
- ListBox2.Items.Add(b & a & t1)
- End If
- ElseIf c = t1 - 1 Then
- If b + c + 1 < s Then
- If p(b + c + 1, a - t1 + 1 + c) = False Then
- p1 += 1
- Else
- a2 -= 1
- End If
- End If
- If a - t1 + 1 + c + 1 < s Then
- If p(b + c, a - t1 + c + 1 + 1) = False Then
- p2 -= 1
- End If
- End If
- t1 = p1
- t2 = p2
- p1 = 0
- p2 = 0
- c = -1
- a = a2
- b = b2
- ListBox2.Items.Add(b & a & t1)
- Else
- ListBox2.Items.Add(p1)
- If b + c + 1 < s - 1 Then
- If p(b + c + 1, a - t1 + 1 + c) = False Then
- p1 += 1
- Else
- a2 -= 1
- End If
- End If
- End If
- Catch ex As Exception
- ListBox2.Items.Add(ex.ToString)
- End Try
- Next
- ListBox2.Items.Add(s1)
- b = s
- a = 0
- End If
- Next
- Next
- For a As Integer = s - 1 To 0 Step -1
- Dim sc As String = ""
- For b As Integer = 0 To s - 1
- If p(b, a) = False Then
- sc = sc & "0"
- Else
- sc = sc & "1"
- End If
- Next
- ListBox2.Items.Add(sc)
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement