過去ログ

???
エクセルのマクロ
Option Explicit
Dim a(5) As Integer
Sub Macro1()
Cells(1, 1).Value = 0
a(5) = 0
Call saiki(1)
End Sub
Sub saiki(ByVal n As Integer)
Dim s As Long
Dim dame As Integer
Dim j As Integer
If n = 1 Then
a(1) = 1
Else
a(n) = 0
End If
While a(n) <= 9
dame = 0
If 1 < n And n < 4 Then
If a(n - 1) = a(n) Then
dame = 1
End If
ElseIf n = 4 Then
If a(3) = a(4) Or a(4) = a(5) Then
dame = 1
End If
End If
If dame = 0 Then
If n < 4 Then
Call saiki(n + 1)
Else
Cells(1, 1).Value = Cells(1, 1).Value + 1
s = a(1)
For j = 2 To 5
s = s * 10 + a(j)
Next j
Cells(Cells(1, 1).Value, 2).Value = s
End If
End If
a(n) = a(n) + 1
Wend
End Sub
   2月6日(木) 10:02:25     41391

過去問題一覧へ戻る