ÇÁ·Î±×·¡¹Ö

 3206, 8/161 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   ¹°¸ÔÀÚ
   c¾ð¾î Áú¹®Á»¿ä

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=2820 [º¹»ç]


/* practice_2 */

#include <stdio.h>

int main(void)
{
        int i=0,cnt;
        int num=0;

        printf("3ÀÇ ¹è¼öÀÇ °³¼ö:");
        scanf("%d",&cnt);

        while(num++<cnt)
        {
                i+=3;
                printf(" %d ",i);
                
        }

        return 0;
}
À§¿¡ ¼Ò½º¶û
while(num<cnt)
{
          i+=3;
          printf(" %d ",i);
          num++;
                
}
À̰Ŷû Ãâ·Â°á°ú°¡ °°Àºµ¥  À§¿¡²« ¿¬»êÈÄ +1 ¾Æ·§°Íµµ ¸¶Âù°¡ÁöÀÔ´Ï´Ù

while(++num<cnt)
{
        i+=3;
        printf(" %d ",i);
                
}


while(num<cnt)
{
          i+=3;
          printf(" %d ",i);
          ++num;
                
}
ÀÌ°Ç  +1ÇÑÈÄ ¿¬»êÀÔ´Ï´Ù ±Ùµ¥ ¿©±â¼­ ¸¸¾à 5¸¦ ÀÔ·ÂÇÞÀ»¶§ À§¿¡²« 4°³ ¾Æ·§°Ç 5°³°¡ Ãâ·ÂµÇ´Âµ¥ ¿Ö ±×·±°Ç°¡¿ä?? µÑ´Ù ¶È°°Àº °á°ú°¡ ³ª¿Í¾ßµÇ´Â°Å ¾Æ´Ñ°¡¿© +1ÈÄ ¿¬»êÀε¥ ´äº¯Á» ºÎŹµå·Á¿ä

  Hit : 3399     Date : 2010/12/27 04:51



    
ruka270 ¸Ç ¸¶·¡ whileÀº ±× À§ÀÇ while°ú numº¯¼ö°¡ º¯°æµÈ °ªÀ» Æò°¡ÇÏ´Â ½ÃÁ¡ÀÌ ´Ù¸¨´Ï´Ù.

while(++num<cnt)
{
i+=3;
printf(" %d ",i);

}
ÀÌ°Ô A

while(num<cnt)
{
i+=3;
printf(" %d ",i);
++num;

}
ÀÌ°Ô B¶ó°í ÇßÀ»¶§

A
num=1 / 1<5 -> continue
num=2 / 2<5 -> continue
num=3 / 3<5 -> continue
num=4 / 4<5 -> continue
num=5 / 5<5 -> exit
A result : 4

B
num=0 / 0<5 -> continue : num+1=1
num=1 / 1<5 -> continue : num+1=2
num=2 / 2<5 -> continue : num+1=3
num=3 / 3<5 -> continue : num+1=4
num=4 / 4<5 -> continue : num+1=5
num=5 / 5<5 -> exit
B result : 5
2010/12/27  
¹°¸ÔÀÚ ¾Æ ¤»¤»¤» °¨»çÇÕ´Ï´Ù 2010/12/27  
3066   httpÇÁ·ÎÅäÄÝ Å¬¶óÀ̾ðÆ® ÇÁ·Î±×·¡¹Ö[7]     ºí·º³²ÀÚ
11/20 2814
3065   °í¼ö´Ôµé ÁÁÀº ´äº¯ ¹Ù·¡¿ä.[3]     ºÐÈ«
06/26 2772
3064     [re] ÇØÄðC¾ð¾î Ã¥Áß.. ¼öÁ¤ÇÒ °÷.     ¹ß¼Û´ã´çÀÚ
11/10 4064
3063   Áú¹®Á» µå¸±²¾¿ä[2]     ¹°¸ÔÀÚ
02/09 3254
3062   c¾ð¾î Áú¹®Á»¿ä[5]     ¹°¸ÔÀÚ
01/22 4152
3061   2Â÷¿ø ¹è¿­ Áú¹®Á»¿ä[4]     ¹°¸ÔÀÚ
01/18 3582
3060   c¾ð¾î ¹è¿­ Áú¹®Á»¿ä[3]     ¹°¸ÔÀÚ
01/09 3569
3059   c¾ð¾î Áú¹®Á»¿ä[4]     ¹°¸ÔÀÚ
01/02 3336
  c¾ð¾î Áú¹®Á»¿ä[2]     ¹°¸ÔÀÚ
12/27 3398
3057   c¾ð¾î Áú¹®Á»¿ä[6]     ¹°¸ÔÀÚ
12/24 3363
3056   c¾ð¾î Áú¹®Á»¿ä[2]     ¹°¸ÔÀÚ
12/23 3146
3055   c c++ Áú¹®Á»¿ä[3]     ¹°¸ÔÀÚ
12/13 3014
3054     [re] c ¾ð¾î Ä·ÆÛ½º°­Á 1À» º¸´Ï±î¿ä     ¹«¼ÒÀ¯
12/17 3584
3053     [re] c¾ð¾î ¾Æ¹«°Íµµ ¸ð¸£´Âµ¥¿ä     ¹«¼ÒÀ¯
12/17 2213
3052   [Æ÷ÀÎÅÍ]C¾ð¾î Áú¹®[2]     ¹Ú¿µ¹Î
03/12 3438
3051   À¸¾Ç ..! °©ÀÚ±â È¥µ·ÀÌ     ¹Ùº¼ÀÌ
07/02 2910
3050   À©µµ¿ì ·Î¿ì ¼ÒÄÏ °ü·Ã Áú¹®ÀÔ´Ï´Ù..[2]     ¹Ùº¼ÀÌ
05/21 5979
3049   À¸Èå...ÆäÀÌ¡°ü·Ã Áú¹®ÀÔ´Ï´Ù..     ¹Ùº¼ÀÌ
04/09 2759
3048   Áö...Áú¹®ÀÌ¿ä..[1]     ¹Ùº¼ÀÌ
12/20 3019
3047   Áú¹®ÀÌ¿ä...¤Ð     ¹Ùº¼ÀÌ
10/16 2751
[1][2][3][4][5][6][7] 8 [9][10]..[161]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org