過去ログ

???
エクセルのマクロ
Option Explicit
Dim a(13) As Integer
'_________12 13
'______09 10 11
'___06 07 08
'03 04 05
'01 02
Sub Macro1()
Cells(1, 1).Value = 0
Call saiki(1)
End Sub
Sub saiki(ByVal n As Integer)
Dim gyou As Integer, j As Integer
a(n) = 1 '1:○, 2:×
While a(n) <= 2
If dame(n) = 0 Then
If n < 13 Then
Call saiki(n + 1)
Else
Cells(1, 1).Value = Cells(1, 1).Value + 1
gyou = Cells(1, 1).Value * 6 - 5
Cells(gyou, 5).Value = masu(a(12))
Cells(gyou, 6).Value = masu(a(13))
Cells(gyou + 1, 4).Value = masu(a(9))
Cells(gyou + 1, 5).Value = masu(a(10))
Cells(gyou + 1, 6).Value = masu(a(11))
Cells(gyou + 2, 3).Value = masu(a(6))
Cells(gyou + 2, 4).Value = masu(a(7))
Cells(gyou + 2, 5).Value = masu(a(8))
Cells(gyou + 3, 2).Value = masu(a(3))
Cells(gyou + 3, 3).Value = masu(a(4))
Cells(gyou + 3, 4).Value = masu(a(5))
Cells(gyou + 4, 2).Value = masu(a(1))
Cells(gyou + 4, 3).Value = masu(a(2))
End If
End If
a(n) = a(n) + 1
Wend
End Sub
Private Function dame(ByVal n As Integer) As Integer
If n = 1 Or a(n) = 2 Then
dame = 0
Else
Select Case n
Case 2, 3
dame = -(a(1) = 1)
Case 4
dame = -(a(2) = 1 Or a(3) = 1)
Case 5, 6
dame = -(a(4) = 1)
Case 7
dame = -(a(5) = 1 Or a(6) = 1)
Case 8, 9
dame = -(a(7) = 1)
Case 10
dame = -(a(8) = 1 Or a(9) = 1)
Case 11, 12
dame = -(a(10) = 1)
Case Else
dame = -(a(11) = 1 Or a(12) = 1)
End Select
End If
End Function
Private Function masu(ByVal n As Integer) As String
If n = 1 Then
masu = "○"
Else
masu = "×"
End If
End Function
   3月20日(木) 11:07:36     41577

過去問題一覧へ戻る