本帖最后由 pusofalse 于 2011-11-17 19:20 编辑
#include <Array.au3>
Const $COUNT = 5
Local $iTimerInit = TimerInit()
Local $iDirect, $aMatrix[$COUNT][$COUNT], $iX = -1, $iY = 0
For $i = 1 To ($COUNT ^ 2 + $COUNT) / 2
Switch $iDirect
Case 0
If $iX + 1 = $COUNT Or $aMatrix[$iX + 1][$iY] Then
$iY += 1
$iDirect = 1
Else
$iX += 1
EndIf
Case 1
If $iY + 1 = $COUNT Or $aMatrix[$iX][$iY + 1] Then
$iDirect = 2
$iX -= 1
$iY -= 1
Else
$iY += 1
EndIf
Case 2
If $aMatrix[$iX - 1][$iY - 1] Then
$iDirect = 0
$iX += 1
Else
$iX -= 1
$iY -= 1
EndIf
EndSwitch
$aMatrix[$iX][$iY] = $i
Next
_ArrayDisplay($aMatrix, TimerDiff($iTimerInit))
|