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

³sÄò & ¤£³sÄò ¤§°}¦C³B²z¤è¦¡ex:1~3,5,7,9~11

³sÄò & ¤£³sÄò ¤§°}¦C³B²z¤è¦¡ex:1~3,5,7,9~11

¦U¦ì¤j¤j¦pÃD,°}¦C¤ºªº¼Æ¦r¤w¸g·|¨Ì·Ó¼Æ¦r¤j¤p¶i¦æ±Æ§Ç,¥Ñ¤p¦Ü¤j
¦ý­n¦p¦ó¹F¨ì¥H¤U®ÄªG©O~?(°}¦Cªø«×¤£¤@©w)
°²³]°}¦C¬°
1,2,3,5,7,9,10,11 =>1~3,5,7,9~11
1,11=>1,11
5,6,8,9=>5~6,8~9

¤]´N¬O¤W¤@­Ó¼Æ¦r»P³o­Ó¼Æ¦r¬O³sÄòªº´N­n¥Î"~"ªí¥Ü,¥B¬Ù²¤¤¤¶¡¼Æ¦r
¦ý­Y¤£¬O³sÄòªº,«h¥H","Åã¥Ü,¥B¤£±o¬Ù²¤¼Æ¦r
PKKO

¦U¦ì¤j¤j¦pÃD,°}¦C¤ºªº¼Æ¦r¤w¸g·|¨Ì·Ó¼Æ¦r¤j¤p¶i¦æ±Æ§Ç,¥Ñ¤p¦Ü¤j
¦ý­n¦p¦ó¹F¨ì¥H¤U®ÄªG©O~?(°}¦Cªø«×¤£¤@©w ...
PKKO µoªí©ó 2014-11-16 05:04
  1. Sub nn()
  2.   Dim iI%
  3.   Dim lL&
  4.   Dim sStr$
  5.   Dim vA, vB
  6.   
  7.   'vA = Array(1, 2, 3, 5, 7, 9, 10, 11)
  8.   'vA = Array(1, 11)
  9.   vA = Array(5, 6, 8, 9)
  10.   ReDim vB(0)
  11.   lL = vA(0)
  12.   sStr = lL
  13.   For iI = 1 To UBound(vA)
  14.     If vA(iI) <> lL + 1 Then
  15.       If vA(iI - 1) <> sStr Then sStr = sStr & "~" & vA(iI - 1)
  16.         vB(UBound(vB)) = sStr
  17.         ReDim Preserve vB(UBound(vB) + 1)
  18.         sStr = vA(iI)
  19.     End If
  20.     lL = vA(iI)
  21.   Next
  22.   If vA(UBound(vA)) <> sStr Then sStr = sStr & "~" & vA(iI - 1)
  23.   vB(UBound(vB)) = sStr
  24. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# luhpro

·PÁ¤j¤jªº¦^ÂÐ,¦ýµLªk¦¨¥\Åã¥Ü,³Ì«áµ²ªG¥u·|¥X²{¥½´X½X¦Ó¤w
PKKO

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-11-17 16:08 ½s¿è

¦^´_ 3# PKKO
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. '1,2,3,5,7,9,10,11 =>1~3,5,7,9~11
  3. Sub Ex()
  4.     Dim Ar(), i As Integer, S As String, Msg As Boolean
  5.     Ar = Array(1, 2, 3, 5, 6, 9, 10, 11, 15)
  6.     S = Ar(0)
  7.     For i = 0 To UBound(Ar)
  8.         If i = UBound(Ar) Then
  9.             If Ar(i) - 1 = Ar(i - 1) Then S = S & Ar(i)
  10.         ElseIf Ar(i) + 1 <> Ar(i + 1) Then
  11.             If Msg Then S = S & Ar(i) & "," & Ar(i + 1)
  12.             If Msg = False Then S = S & "," & Ar(i + 1)
  13.             Msg = False
  14.         ElseIf Ar(i) + 1 = Ar(i + 1) Then
  15.            Msg = True
  16.            S = S & IIf(Right(S, 1) <> "~", "~", "")
  17.         End If
  18.     Next
  19.     MsgBox S
  20. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE


    ·PÁª©¤j,§¹¥þ¥¿½T!,¥B§¹¥þ©ú¥Õ¤F!!
PKKO

TOP

¦^´_  GBKEE


    ·PÁª©¤j,§¹¥þ¥¿½T!,¥B§¹¥þ©ú¥Õ¤F!!
PKKO µoªí©ó 2014-11-17 22:46



§Ú«Ü¦n©_

¬°¦ó luhpro¤jªº , §A·|µLªk¦¨¥\

§Ú¸ÕµÛokªº

TOP

Dear ¥u·|¥X²{§À¼Æ(8~9)
  1. Sub nn()

  2.   Dim iI%

  3.   Dim lL&

  4.   Dim sStr$

  5.   Dim vA, vB

  6.   

  7.   'vA = Array(1, 2, 3, 5, 7, 9, 10, 11)

  8.   'vA = Array(1, 11)

  9.   vA = Array(1, 6, 8, 9)

  10.   ReDim vB(0)

  11.   lL = vA(0)

  12.   sStr = lL

  13.   For iI = 1 To UBound(vA)

  14.     If vA(iI) <> lL + 1 Then

  15.       If vA(iI - 1) <> sStr Then sStr = sStr & "~" & vA(iI - 1)

  16.         vB(UBound(vB)) = sStr

  17.         ReDim Preserve vB(UBound(vB) + 1)

  18.         sStr = vA(iI)

  19.     End If

  20.     lL = vA(iI)

  21.   Next

  22.   If vA(UBound(vA)) <> sStr Then sStr = sStr & "~" & vA(iI - 1)

  23.   vB(UBound(vB)) = sStr
  24.     MsgBox vB(UBound(vB))
  25. End Sub
½Æ»s¥N½X
¦^´_ 6# bobomi
PKKO

TOP

  1. Sub ex()
  2. Dim Ay()
  3. ar = Array(1, 2, 3, 5, 7, 9, 10, 11, 13, 14, 15) '¤£³sÄò°}¦C
  4. For i = 0 To UBound(ar) - 1 ''¤£³B²z³Ì«á¤¸¯À
  5.    j = i
  6.    x = ar(j)
  7.       Do Until ar(j) + 1 <> ar(j + 1)
  8.          j = j + 1
  9.          If j = UBound(ar) Then Exit Do
  10.       Loop
  11.    y = ar(j)
  12.    i = j
  13.    ReDim Preserve Ay(s)
  14.    Ay(s) = IIf(x = y, x, x & "~" & y)
  15.    s = s + 1
  16. Next
  17. If j = UBound(ar) - 1 Then '³B²z³Ì«á¤¸¯À
  18. ReDim Preserve Ay(s)
  19. Ay(s) = ar(UBound(ar))
  20. End If
  21. MsgBox Join(Ay, ",")
  22. End Sub
½Æ»s¥N½X
¦^´_ 7# PKKO
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 7# PKKO
¬O¥i¥Hªº
  1.   vB(UBound(vB)) = sStr
  2.     MsgBox Join(vB, ",")
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

·PÁ¨â¦ì¶Wª©ªº«ü±Ð,¥H¤Îbobomi ªº´£¿ô,­ì¨Ó¬O¤p§Ì²¨©¿¤F,·P®¦!!
PKKO

TOP

        ÀR«ä¦Û¦b : ÀR§¤±`®¦¤v¹L¡B¶¢½Í²ö½×¤H«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD