類似土法煉鋼的,大概知道規律,但還寫不出規律來。 只有4跟8而已。 Dim x As Long Dim a() Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 b = 1 c = 1 Input #1, n x = n * n ReDim a((n / 2), n, n) e = 16 For i = 1 To (n / 2) Call re(b, i, e) b = b + 16 e = e + 16 Next If n = 8 Then For i = 1 To n c = a(1, i, 1) a(1, i, 1) = a(4, i, 1) a(4, i, 1) = c c = a(1, 3, i) a(1, i, 3) = a(4, i, 3) a(4, i, 3) = c c = a(2, i, 1) a(2, i, 1) = a(3, i, 1) a(3, i, 1) = c c = a(2, i, 3) a(2, i, 3) = a(3, i, 3) a(3, i, 3) = c Next For i = 1 To 4 f = 1 For j = 1 To 4 Print #2, a(f, i, j); Next f = 3 For j = 1 To 4 Print #2, a(f, i, j); Next Print #2, Next For i = 1 To 4 f = 4 For j = 1 To 4 Print #2, a(f, i, j); Next f = 2 For j = 1 To 4 Print #2, a(f, i, j); Next Print #2, Next End If If n = 4 Then For i = 1 To 4 For j = 1 To 4 Print #2, a(1, i, j); Next Print #2, Next End If Close Close End End Sub Sub re(b, c, e) For i = b To e Select Case i Mod 16 Case 0 a(c, 4, 1) = i Case 1 a(c, 1, 1) = i Case 2 a(c, 2, 1) = i Case 3 a(c, 3, 2) = i Case 4 a(c, 4, 2) = i Case 5 a(c, 4, 3) = i Case 6 a(c, 3, 4) = i Case 7 a(c, 2, 3) = i Case 8 a(c, 1, 4) = i Case 9 a(c, 4, 4) = i Case 10 a(c, 3, 3) = i Case 11 a(c, 2, 4) = i Case 12 a(c, 1, 3) = i Case 13 a(c, 1, 2) = i Case 14 a(c, 2, 2) = i Case 15 a(c, 3, 1) = i End Select Next End Sub
類似土法煉鋼的,大概知道規律,但還寫不出規律來。
回覆刪除只有4跟8而已。
Dim x As Long
Dim a()
Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
b = 1
c = 1
Input #1, n
x = n * n
ReDim a((n / 2), n, n)
e = 16
For i = 1 To (n / 2)
Call re(b, i, e)
b = b + 16
e = e + 16
Next
If n = 8 Then
For i = 1 To n
c = a(1, i, 1)
a(1, i, 1) = a(4, i, 1)
a(4, i, 1) = c
c = a(1, 3, i)
a(1, i, 3) = a(4, i, 3)
a(4, i, 3) = c
c = a(2, i, 1)
a(2, i, 1) = a(3, i, 1)
a(3, i, 1) = c
c = a(2, i, 3)
a(2, i, 3) = a(3, i, 3)
a(3, i, 3) = c
Next
For i = 1 To 4
f = 1
For j = 1 To 4
Print #2, a(f, i, j);
Next
f = 3
For j = 1 To 4
Print #2, a(f, i, j);
Next
Print #2,
Next
For i = 1 To 4
f = 4
For j = 1 To 4
Print #2, a(f, i, j);
Next
f = 2
For j = 1 To 4
Print #2, a(f, i, j);
Next
Print #2,
Next
End If
If n = 4 Then
For i = 1 To 4
For j = 1 To 4
Print #2, a(1, i, j);
Next
Print #2,
Next
End If
Close
Close
End
End Sub
Sub re(b, c, e)
For i = b To e
Select Case i Mod 16
Case 0
a(c, 4, 1) = i
Case 1
a(c, 1, 1) = i
Case 2
a(c, 2, 1) = i
Case 3
a(c, 3, 2) = i
Case 4
a(c, 4, 2) = i
Case 5
a(c, 4, 3) = i
Case 6
a(c, 3, 4) = i
Case 7
a(c, 2, 3) = i
Case 8
a(c, 1, 4) = i
Case 9
a(c, 4, 4) = i
Case 10
a(c, 3, 3) = i
Case 11
a(c, 2, 4) = i
Case 12
a(c, 1, 3) = i
Case 13
a(c, 1, 2) = i
Case 14
a(c, 2, 2) = i
Case 15
a(c, 3, 1) = i
End Select
Next
End Sub