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

Âù­« for loop ½Ð±Ð¦L¬P¬P

Âù­« for loop ½Ð±Ð¦L¬P¬P

½Ð±Ð ªO¤Í  «ç¥Î Âù­«ªº for °j°é   ¨Ó °µ¨ìµe­± ªº¬P¬P ½b¼L?

star.PNG (4.75 KB)

star.PNG

star.rar (5.62 KB)

¥»©«³Ì«á¥Ñ luhpro ©ó 2021-11-26 00:26 ½s¿è
½Ð±Ð ªO¤Í  «ç¥Î Âù­«ªº for °j°é   ¨Ó °µ¨ìµe­± ªº¬P¬P ½b¼L?
adrian_9832 µoªí©ó 2021-11-24 15:23


¨ä¹ê³o¥i¥H¬Ý¦¨³æ¯Âªº¼Æ¾Ç­pºâ :
1. ±q¥ª¨ì¥k¦@8Äæ : iI = 1 to 8

2. :±q¤W¨ì¤U¦³¬P¸¹ªº¦C¸¹¨Ì§Ç¬°: 3 to 3, 2 to 4, 1 to 5, 3 to 3, 3 to 3.....

¬G¦Ó °_¦C ¬° 3, 2, 1, 3, 3......
¦Ó¥½¦C¬° : 3, 4, 5, 3, 3......
¥i¥H©úÅã°Ï¤À¬°4¥H¤U(¤À§O¦U¼W´î1) ¤Î 3¥H¤W(³£¬O3) ¨â­Ó°Ï¶ôºâ¦¡

«h¥i¥H±o¤U¦¡ :
°_¦C :(¤U¦¡¶K¨ì§Y®É¹Bºâµøµ¡°õ¦æ¥iª¾ºâ¦¡µ²ªG)
For iI = 1 To 8: iJ = -(4 - iI) * (iI < 4) - (iI > 3) * 3: Debug.Print iI, iJ: Next

¦Ó¥½¦C«h¬° :
For iI = 1 To 8: iJ = -(2 + iI) * (iI < 4) - (iI > 3) * 3: Debug.Print iI, iJ: Next

ºî¦X¤W­z«h¥i±o :
  1. Sub nn()
  2.   Dim iI%, iJ%, iK%
  3.   
  4.   Range(Cells(1, 1), Cells(5, 8)).ClearContents ' ²M°£¬P¸¹
  5.   
  6.   For iI = 1 To 8
  7.     iK = (iI > 3) * 3 ' ´î¸¹«á­±ªººâ¦¡
  8.     For iJ = -(4 - iI) * (iI < 4) - iK To -(2 + iI) * (iI < 4) - iK
  9.       Cells(iJ, iI) = "*"
  10.     Next iJ
  11.   Next iI
  12. End Sub
½Æ»s¥N½X
Âù­«forloop½Ð±Ð¦L¬P¬Pstar-a.zip (13.39 KB)

TOP

Sub TEST_A1()
Dim R%, Rx%, C%, Cx%, j%
R = 5: C = 8: Cx = Int(R / 2) + 1
For j = 1 To C
    Rx = Cx - j + 1: If Rx < 1 Then Rx = Cx
    Cells(Rx, j).Resize(R - Rx * 2 + 2) = "*"
Next j
End Sub

TOP

ÁÂÁ¨â¦ì¤j¤jªº«ü¾É!

TOP

¦^´_ 3# ­ã´£³¡ªL


    ½Ð°Ý¤j¤j ¦pªG §ï¦¨ debug.print ¨Ó¬Ý ­n«ç§ï??

TOP

¦^´_ 2# luhpro


    (iI < 4) - iK   
½Ð°Ý ¦bFOR LOOP ¤¤ ³o­Ó¬O«ç»ò²z¸Ñ?

TOP

¦^´_ 3# ­ã´£³¡ªL


    ½Ð°Ý¦³ DEBUG.PRINT ªºª©¥»¶Ü

TOP

        ÀR«ä¦Û¦b : ¤Hªº²´·úªø¦b«e­±¡A¥u¬Ý¨ì§O¤Hªº¯ÊÂI¡Aµ·²@¬Ý¤£¨ì¦Û¤vªº¯ÊÂI¡C
ªð¦^¦Cªí ¤W¤@¥DÃD