Grid Path (Algorithm Source)

xiaoxiao2021-04-06  247

'1 ---- 2 ---- 3' | | | '4 ---- 5 ---- 6' | | | '7 ---- 8 ---- 9' Field Shaped Grid There are 9 points, and now the 'programming lists all the paths from any point to any point. (You can only take one each)

Save the following to text files and change the file extension to .frm

VERSION 5.00Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3930 ClientLeft = 60 ClientTop = 345 ClientWidth = 7620 LinkTopic = "Form1" ScaleHeight = 3930 ScaleWidth = 7620 StartUpPosition = 3 'default window Begin VB.ComboBox Combo2 Height = 300 Left = 2160 TabIndex = 6 Text = "Combo1" Top = 2400 Width = 615 End Begin VB.ComboBox Combo1 Height = 300 Left = 600 TabIndex = 5 Text = "1" Top = 2400 Width = 615 End Begin VB.TextBox Text3 Height = 3855 Left = 3120 multiline = -1 'True scrollbars = 2' vertical TabINDEX = 4 TOP = 0 width = 4455 End begin vb.commandbutton Command1 CAPTION = "Solving" Height = 375 Left = 1920 TabINDEX = 0 TOP = 3240 width = 1095 End Begin vb.Label Label2 AutoSize = -1 'True Caption = "Terminal:" Height = 180 INDEX = 1 Left = 1560 TabIndex = 3 TOP = 2490 width = 540 End Begin vb.Label Label2 Autozize = -1 '

True caption = "starting point:" Height = 180 index = 0 left = 0 TabINDEX = 2 TOP = 2490 width = 540 End begin vb.label label1 caption = $ "form1.frx": 0000 Height = 1455 left = 0 TabINDEX = 1 Top = 240 Width = 3015 EndEndAttribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption Explicit'1 ---- 2 ---- 3 '| | |' 4 ---- 5- --- 6 '| | | 9 ---- 8 ---- 9' field-shaped grid has 9 points, now the 'programming lists all paths from any point to another. (You can only take one per point) DIM A (2, 2) as Boolean, x, y, b (8)

Private submmand1_click () DIM WZS AS INTEGER, MBS AS INTEGER ERASE A x = array (-1, 0, 1, 0) y = array (0, -1, 0, 1) WZS = Combo1.Text: MBS = Combo2 .Text A (WZS - 1) MOD 3, (WZS - 1) / 3) = true: b (0) = WZS text3 = "From the starting point position [" & WZS & "] to the end position [" & MBS & MBS & MBS & "] The non-repetition path is:" & Vbcrlf Call DG (1, WZS, MBS, A) end SUB

SUB DG (T, WZ, MB, A) DIM I AS INTEGER, X1 AS INTEGER, Y1 AS INTEGER, SZ AS INTEGER, J AS Integer for i = 0 to 3 x1 = (WZ - 1) MOD 3 X (i : Y1 = (WZ - 1) / 3 y (i) IF x1> = 0 AND Y1> = 0 AND x1 <3 and y1 <3 Then IF A (x1, y1) = false theen SZ = Y1 * 3 x1 1: b (t) = sz if SZ = MB THEN for J = 0 to T TEXT3 = TEXT3 & B (J) & IIF (j

转载请注明原文地址:https://www.9cbs.com/read-132309.html

New Post(0)