ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

°ÊºA°}¦C (±Æ¦C²Õ¦X)

°ÊºA°}¦C (±Æ¦C²Õ¦X)

¦U¦ì«e½ú¦n
½Ð±Ð°ÊºA°}¦C
1.¤U¦Cµ{¦¡½Xªº°}¦C¼Æ¬O5­Ó
2.¥ô·N­Ó°}¦C¼Æ³£¯à¦C¥X¨ä±Æ¦C²Õ¦X­n¦p¦ó³]­p?
ÁÂÁ«ü¾É

Option Explicit
Sub TEST_20210927()
Dim i&, C&, Arr, Brr, x&
Arr = Array(1, 10, 100, 1000, 10000)
ReDim Brr(0 To 100, 1)
C = 0
For i = 0 To UBound(Arr)
   Brr(C, 0) = Arr(i)
   Brr(C, 1) = "³æ¤@"
   C = C + 1
Next
For i = 0 To UBound(Arr)
   For x = i + 1 To UBound(Arr)
      Brr(C, 0) = Arr(i) + Arr(x)
      Brr(C, 1) = "2­Ó¬Û¥["
      C = C + 1
   Next
Next
For i = 0 To UBound(Arr) - 1
   For x = i + 1 To UBound(Arr) - 1
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1)
      Brr(C, 1) = "3­Ó¬Û¥["
      C = C + 1
   Next
Next
For i = 0 To UBound(Arr) - 3
   For x = i + 1 To UBound(Arr) - 2
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2)
      Brr(C, 1) = "4­Ó¬Û¥["
      C = C + 1
   Next
Next
For i = 0 To UBound(Arr) - 4
   For x = i + 1 To UBound(Arr) - 3
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3)
      Brr(C, 1) = "5­Ó¬Û¥["
      C = C + 1
   Next
Next
[A1].Resize(UBound(Arr) + 1, 1) = Application.Transpose(Arr)
[B1].Resize(UBound(Brr), 2) = Brr
End Sub

¸É¥R»¡©ú
°}¦C¸Ìªº­È¤£¤@©w¬O10ªº­¿¼Æ,¬O¥ô·Nªº¥¿¾ã¼Æ
³o½d¨Ò¥u¬O¦Û¤v¤è«K§PÂ_¥Îªº
¤£¦n·N«ä!¨S¥æ¥N²M·¡!
ÁÂÁ«ü¾É!

TOP

¦^´_ 1# Andy2483


    ¤Ö¤F´X­Ó²Õ¦X

Option Explicit
Sub TEST_20210928() '
Dim i&, C&, Arr, Brr, x&
Arr = Array(1, 10, 100, 1000, 10000)
ReDim Brr(0 To 1000, 1)
C = 0
For i = 0 To UBound(Arr)
   Brr(C, 0) = Arr(i)
   Brr(C, 1) = "³æ¤@"
   C = C + 1
Next
For i = 0 To UBound(Arr)
   For x = i + 1 To UBound(Arr)
      Brr(C, 0) = Arr(i) + Arr(x)
      Brr(C, 1) = "2­Ó¬Û¥["
      C = C + 1
   Next
Next
For i = 0 To UBound(Arr) - 1
   For x = i + 1 To UBound(Arr) - 1
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1)
      Brr(C, 1) = "3­Ó¬Û¥["
      C = C + 1
   Next
   For x = i + 1 To UBound(Arr) - 2
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 2)
      Brr(C, 1) = "3­Ó¬Û¥["
      C = C + 1
   Next
   For x = i + 1 To UBound(Arr) - 3
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 3)
      Brr(C, 1) = "3­Ó¬Û¥["
      C = C + 1
   Next
Next
For i = 0 To UBound(Arr) - 3
   For x = i + 1 To UBound(Arr) - 2
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2)
      Brr(C, 1) = "4­Ó¬Û¥["
      C = C + 1
   Next
   For x = i + 1 To UBound(Arr) - 3
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 2) + Arr(x + 3)
      Brr(C, 1) = "4­Ó¬Û¥["
      C = C + 1
   Next
   For x = i + 1 To UBound(Arr) - 3
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 3)
      Brr(C, 1) = "4­Ó¬Û¥["
      C = C + 1
   Next
   For x = i + 2 To UBound(Arr) - 3
      Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3)
      Brr(C, 1) = "4­Ó¬Û¥["
      C = C + 1
   Next
Next
For i = 0 To UBound(Arr) - 4
   For x = i + 1 To UBound(Arr) - 3
      Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3)
      Brr(C, 1) = "5­Ó¬Û¥["
      C = C + 1
   Next
Next
Workbooks.Add
[A1].Resize(UBound(Arr) + 1, 1) = Application.Transpose(Arr)
[B1].Resize(UBound(Brr), 2) = Brr
End Sub

TOP

°}¦C¼Æ 2  ­Ó> ±Æ¦C²Õ¦X 3 ­Ó
°}¦C¼Æ 3  ­Ó> ±Æ¦C²Õ¦X 7 ­Ó
°}¦C¼Æ 4  ­Ó> ±Æ¦C²Õ¦X 15 ­Ó
°}¦C¼Æ 5  ­Ó> ±Æ¦C²Õ¦X 31 ­Ó
°}¦C¼Æ 6  ­Ó> ±Æ¦C²Õ¦X 63 ­Ó

Âk¯Ç°_¨Ó¬O 2 ªº N¦¸¤è­Ó (N¬O°}¦C¼Æ)
¤U¦Cµ{¦¡½X¥i±Æ¦C¥X °}¦C¼Æ 6  ­Ó> ±Æ¦C²Õ¦X 63 ­Ó
½Ð±Ð¦U¦ì«e½ú ¦³¿ìªk²¤Æ¨Ã¥[¨ì°}¦C¼Æ 100  ­Ó¶Ü?
ÁÂÁ«ü¾É!

Option Explicit
Sub TEST_20210928_1()
Dim i&, C&, Arr, Brr, x&
Arr = Array(1, 10, 100, 1000, 10000, 100000)
ReDim Brr(0 To 1000, 1)
C = 0
On Error Resume Next
For i = 0 To UBound(Arr)
   Brr(C, 0) = Arr(i)
   Brr(C, 1) = "³æ¤@"
   C = C + 1
Next
For i = 0 To UBound(Arr)
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x)
         Brr(C, 1) = "2­Ó¬Û¥["
         C = C + 1
      End If
   Next
Next
For i = 0 To UBound(Arr)
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 2)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 3)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 4)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 3)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 4)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 2) + Arr(x + 3)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 2) + Arr(x + 4)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "3­Ó¬Û¥["
         C = C + 1
      End If
   Next
Next
For i = 0 To UBound(Arr)
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 3)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 4)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 2) + Arr(x + 3)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 2) + Arr(x + 4)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 4)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 2) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "4­Ó¬Û¥["
         C = C + 1
      End If
   Next
Next

For i = 0 To UBound(Arr)
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 2) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x) + Arr(x + 1) + Arr(x + 2) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
   For x = i To UBound(Arr)
      If i <> x Then
         Brr(C, 0) = Arr(i) + Arr(x + 1) + Arr(x + 2) + Arr(x + 3) + Arr(x + 4)
         Brr(C, 1) = "5­Ó¬Û¥["
         C = C + 1
      End If
   Next
Next
Brr(C, 0) = Arr(0) + Arr(1) + Arr(2) + Arr(3) + Arr(4) + Arr(5)
Brr(C, 1) = "6­Ó¬Û¥["
Workbooks.Add
[A1].Resize(UBound(Arr) + 1, 1) = Application.Transpose(Arr)
[B1].Resize(UBound(Brr), 2) = Brr
[B:B].AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Columns _
        ("E:E"), Unique:=True
[E:E].Sort _
KEY1:=[E1], Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, SortMethod:=xlStroke, _
DataOption1:=xlSortNormal
End Sub

TOP

§ä¨ì¤èªk¤F! ÁÂÁ¦U¦ì«e½ú.stillfish00,PKKO
°Ñ¦Ò©«¤l: http://forum.twbts.com/viewthread.php?tid=18001

Option Explicit
Sub ListCombination_Add()
Dim Arr, n&, i&, j&, Brr
Arr = Array(1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000#)
n = UBound(Arr) - LBound(Arr) + 1
ReDim Brr(1 To 2 ^ n - 1, 1 To n + 1)
For i = 1 To 2 ^ n - 1
   For j = 0 To n - 1
      If i And 2 ^ j Then
         Brr(i, j + 1) = Arr(j)
         Brr(i, n + 1) = Brr(i, n + 1) + Arr(j)
      End If
   Next
Next
Workbooks.Add
Cells.ClearContents
[A1].Resize(UBound(Brr), UBound(Brr, 2)) = Brr
Cells.Columns.AutoFit
End Sub

TOP

        ÀR«ä¦Û¦b : ¦Y­W¤F­W¡B­WºÉ¤Ü¨Ó¡A¨ÉºÖ¤FºÖ¡BºÖºÉ´d¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD