Advertisement
Guest User

Untitled

a guest
May 25th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.94 KB | None | 0 0
  1.  
  2. Dim item As String = ListBox1.GetItemText(ListBox1.Items.Item(0))
  3. Dim n As Integer = 0, s As Integer = 0
  4. For a As Integer = 0 To item.Length - 1
  5. If item.Chars(a) <> " " Then
  6. n = Val(CStr(n) & item.Chars(a))
  7. Else
  8. For b As Integer = a + 1 To item.Length - 1
  9. s = Val(CStr(s) & item.Chars(b))
  10. a = item.Length
  11. Next
  12. End If
  13. Next
  14. Dim p(s + 1, s + 1) As Boolean
  15. For a As Integer = s To 0
  16. For b As Integer = 0 To s
  17. p(a, b) = False
  18. Next
  19. Next
  20. For a As Integer = s - 1 To 0
  21. For b As Integer = 0 To s - 1
  22. p(a, b) = False
  23. Next
  24. Next
  25. For a As Integer = 1 To n
  26. Dim sm As String = 0, x As String = 0, y As String = 0
  27. item = ListBox1.GetItemText(ListBox1.Items.Item(a))
  28. For b As Integer = 0 To item.Length - 1
  29. If item.Chars(b) <> " " Then
  30. sm = sm & item.Chars(b)
  31. Else
  32. For c As Integer = b + 1 To item.Length - 1
  33. If item.Chars(c) <> " " Then
  34. x = x & item.Chars(c)
  35. Else
  36. For d As Integer = c + 1 To item.Length - 1
  37. y = y & item.Chars(d)
  38. Next
  39. b = item.Length
  40. c = item.Length
  41. End If
  42. Next
  43. End If
  44. Next
  45. For b As Integer = 0 To Val(sm) - 1
  46. For c As Integer = 0 To Val(sm) - 1
  47. p(c + Val(x), b + Val(y)) = True
  48. Next
  49. Next
  50. Next
  51. For a As Integer = s - 1 To 0 Step -1
  52. Dim sc As String = ""
  53. For b As Integer = 0 To s - 1
  54. If p(b, a) = False Then
  55. sc = sc & "0"
  56. Else
  57. sc = sc & "1"
  58. End If
  59. Next
  60. ListBox1.Items.Add(sc)
  61. Next
  62. p(9, 7) = True
  63. For a As Integer = s - 1 To 0 Step -1
  64. For b As Integer = 0 To s - 1
  65. If p(b, a) = False Then
  66. Dim a1, b1 As Integer
  67. a1 = a
  68. b1 = b
  69. Dim a2, b2 As Integer
  70. a2 = a
  71. b2 = b
  72. Dim t1 As Integer = 0, t2 As Integer = 0
  73. If b + 1 < s Then
  74. If p(b + 1, a) = False Then
  75. t1 = t1 + 1
  76. Else
  77. a2 -= 1
  78. End If
  79. End If
  80. If b - 1 > 0 Then
  81. If p(b - 1, a) = False Then
  82. t2 -= 1
  83. End If
  84. End If
  85. If a + 1 < s Then
  86. If p(b, a + 1) = False Then
  87. t2 -= 1
  88. End If
  89. End If
  90. If a - 1 > 0 Then
  91. If p(b, a - 1) = False Then
  92. t1 = t1 + 1
  93. Else
  94. b2 += 1
  95. End If
  96. End If
  97. b = b2
  98. a = a2
  99. Dim p1, p2 As Integer
  100. p1 = 0
  101. p2 = 0
  102. p(b, a) = True
  103. Dim s1 As Integer = 1
  104. For c As Integer = 0 To t1
  105. ListBox2.Items.Add("@" & b + c & a - t1 + 1 + c & c)
  106. Try
  107. p(b + c, a - t1 + 1 + c) = True
  108. If c = 0 Then
  109. If b + c + 1 < s Then
  110. If p(b + c + 1, a - t1 + 1 + c) = False Then
  111. p1 += 1
  112. ElseIf p(b + c + 1, a - t1 + 1 + c) = True And p(b + c, a - t1 + 1 + c - 1) = False Then
  113. a2 -= 1
  114. End If
  115. End If
  116. If b + c - 1 > 0 Then
  117. If p(b + c - 1, a - t1 + 1 + c) = False Then
  118. p2 -= 1
  119. End If
  120. End If
  121. If a - t1 + 1 + c - 1 > 0 Then
  122. If p(b + c, a - t1 + 1 + c - 1) = False Then
  123. p1 += 1
  124. Else
  125. b2 += 1
  126. End If
  127. End If
  128. If c = t1 - 1 Then
  129. If a - t1 + 1 + c + 1 < s Then
  130. If p(b + c, a - t1 + c + 1 + 1) = False Then
  131. p2 -= 1
  132. End If
  133. End If
  134. t1 = p1
  135. t2 = p2
  136. p1 = 0
  137. p2 = 0
  138. c = -1
  139. a = a2
  140. b = b2
  141. ListBox2.Items.Add(b & a & t1)
  142. End If
  143. ElseIf c = t1 - 1 Then
  144. If b + c + 1 < s Then
  145. If p(b + c + 1, a - t1 + 1 + c) = False Then
  146. p1 += 1
  147. Else
  148. a2 -= 1
  149. End If
  150. End If
  151. If a - t1 + 1 + c + 1 < s Then
  152. If p(b + c, a - t1 + c + 1 + 1) = False Then
  153. p2 -= 1
  154. End If
  155. End If
  156. t1 = p1
  157. t2 = p2
  158. p1 = 0
  159. p2 = 0
  160. c = -1
  161. a = a2
  162. b = b2
  163. ListBox2.Items.Add(b & a & t1)
  164. Else
  165. ListBox2.Items.Add(p1)
  166. If b + c + 1 < s - 1 Then
  167. If p(b + c + 1, a - t1 + 1 + c) = False Then
  168. p1 += 1
  169. Else
  170. a2 -= 1
  171. End If
  172. End If
  173. End If
  174. Catch ex As Exception
  175. ListBox2.Items.Add(ex.ToString)
  176. End Try
  177. Next
  178. ListBox2.Items.Add(s1)
  179. b = s
  180. a = 0
  181. End If
  182. Next
  183. Next
  184. For a As Integer = s - 1 To 0 Step -1
  185. Dim sc As String = ""
  186. For b As Integer = 0 To s - 1
  187. If p(b, a) = False Then
  188. sc = sc & "0"
  189. Else
  190. sc = sc & "1"
  191. End If
  192. Next
  193. ListBox2.Items.Add(sc)
  194. Next
  195. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement