- ©«¤l
- 2025
- ¥DÃD
- 13
- ºëµØ
- 0
- ¿n¤À
- 2053
- ÂI¦W
- 0
- §@·~¨t²Î
- WIN7
- ³nÅ骩¥»
- Office2007
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_¥«
- µù¥U®É¶¡
- 2011-3-2
- ³Ì«áµn¿ý
- 2024-3-14
|
- Option Base 1
- Sub ¥H±ÛÂà¤è¦¡¶ñ¤JÈ()
- xc = 10: yc = 10 '¤¤¤ß¦ì¸m
- ¥k = [{0, 1}]: ¤U = [{1,0}]: ¥ª = [{0,-1}]: ¤W = [{-1, 0}]
- yx = Application.Transpose(Application.Transpose(Array(¥k, ¤U, ¥ª, ¤W))) '±±¨î¤è¦V¤ÎÂà¦V
-
- n = InputBox("¿é¤J±Æ¦C¼Æ¦r", , 25)
- n1 = Application.RoundUp(((n ^ 0.5) - 1) / 2, 0) + 1
- nn = n1 * 2 + 1
- Cells(yc - n1, xc - n1).Resize(nn, nn).ClearContents
- x = xc: y = yc
- Cells(xc, yc) = 1
- For i = 2 To n
- ds = [{0,0,0,0}]
- For j = 1 To 4 '¥|Ó¤è¦V
- If Cells(y + yx(j, 1), x + yx(j, 2)) = "" Then
- ds(j) = ((y + yx(j, 1) - yc) ^ 2 + (x + yx(j, 2) - xc) ^ 2) * 10 + j '¶ZÂ÷*10+¤è¦V
- Else
- ds(j) = ""
- End If
- Next
- jj = Application.Min(ds) Mod 10 '¨ú¶ZÂ÷ìÂI³Ìµu¤Î±Æ¦C³Ì«e¤è¦V
- x = x + yx(jj, 2)
- y = y + yx(jj, 1)
- Cells(y, x) = i
- Next
- End Sub
½Æ»s¥N½X |
-
1
µû¤À¤H¼Æ
-
|