1600, 1/80 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   lackhole
   Penguins.png (18.4 KB), Download : 19     [¿À¸¥ÂÊ ¹öÆ° ´­·¯ ´Ù¿î ¹Þ±â]
   [Æß]C Language (swap)

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



c¾ð¾î swap¿¹Á¦

a ¿¡´Ù 1À» ÀÔ·ÂÇÏ°í b¿¡´Ù 2¸¦ ÀÔ·ÂÇÏ°í a¿ÍbÀÇ °ªÀ» ¹Ù²Ù´Â ¿¹Á¦¸¦ ¸¸µé¶ó°í ÇÑ´Ù¸é c¾ð¾î¸¦ ÃʹÝÀ¸·Î Á¢ÇϽô ºÐµéÀº ¾Æ·¡¿Í °°ÀÌ ÀÛ¼ºÇÒ¼öµµ ÀÖ´Ù

#include <Stdio.h>

int main(void)
{
        int a , b;
        
        printf("a :");
        scanf("%d",&a); //1·Î ÀÔ·ÂÇÑ°æ¿ì
        
        printf("b :");
        scanf("%d",&b); //2·Î ÀÔ·ÂÇÑ°æ¿ì
        
        b = a;  
        a = b;  
        
        printf("a : %d\nb : %d\n",a , b);
        
        return 0;
}
c¾ð¾î¸¦ ÃʹÝÀ¸·Î Á¢ÇϽŠºÐÀº ÀÌ·¸°Ô ÀÛ¼ºÇÒ¼öµµ ÀÖ½À´Ï´Ù.

ÇÏÁö¸¸ ÀÌ·¸°Ô ÀÛ¼ºÇϸé
b=a;
a=b;
ºÎºÐ¿¡¼­ °ª¼Õ½ÇÀÌ ÀϾ´Ï´Ù.
ÀÏ´Ü aÀÇ °ªÀ» b¿¡´Ù ³Ö¾ú½À´Ï´Ù.c¾ð¾î´Â À§¿¡¼­ ¾Æ·¡·Î Àб⠶§¹®¿¡
a=b;¿¡¼­ a°ª¿¡´Ù b¸¦ ³ÖÁö¸¸  À§¿¡¼­ bÀÇ °ªÀÌ a·Î ¹Ù²ï »óÅ·ΠµÇ±â¶§¹®¿¡ µÑ´Ù aÀÇ °ª°ú µ¿ÀÏÇØÁø´Ù´Â ¿À·ù°¡ ÀÖ½À´Ï´Ù.
±×·¡¼­ swapÀº ¾Æ·¡¿Í °°Àº ÄÚµå

#include <Stdio.h>

int main(void)
{
        int a , b;
        int tmp = 0; //temporay
        
        printf("a :");
        scanf("%d",&a); //1·Î ÀÔ·ÂÇÑ°æ¿ì
        
        printf("b :");
        scanf("%d",&b); //2·Î ÀÔ·ÂÇÑ °æ¿ì
        
        tmp = b;  //b°ª ¹Ì¸® ÀúÀå
        b = a;  //b°ªÀÌ a·Î ¹Ù²ñ  //swap
        a = tmp;  //aÀÇ °ªÀº tmpÀÇ ÀúÀåµÈ bÀÇ °ª
        
        printf("a : %d\nb : %d\n",a , b);
        
        return 0;
}

ÀÌ·¸°Ô bÀÇ °ªÀ» ¹Ì¸® tmp¶ó´Â º¯¼öÀÇ ÀúÀåÀ»ÇØÁÖ°í
a = tmp;·Î ÀúÀåµÈ bÀÇ °ªÀ» °¡Á®¿É´Ï´Ù'


  Hit : 8148     Date : 2015/10/17 07:38



    
wsj7178 ÀÌ°É ÀÌ¿ëÇؼ­ ÇÔ¼öµµ ¸¸µé¼ö ÀÖÁÒ
void swap(int *x, int *y)
{
int tmp;
tmp = *x;
*x = *y;
*y = tmp;
}
2015/11/29  
     [°øÁö] °­Á¸¦ ¿Ã¸®½Ç ¶§´Â ¸»¸Ó¸®¸¦ ´Þ¾ÆÁÖ¼¼¿ä^¤Ñ^ [29] ¸Û¸Û 02/27 19536
1599   [overthewire.org] - leviathan1     ÇØÅ·ÀßÇÏ°í½Í´Ù
01/14 28
1598   [overthewire.org] - leviathan0     ÇØÅ·ÀßÇÏ°í½Í´Ù
01/14 15
1597   [Write Up] Crypto Cat's CTF 2024 - BabyFlow     ÇØÅ·ÀßÇÏ°í½Í´Ù
12/29 97
1596   [pwnable.kr] bof     ÇØÅ·ÀßÇÏ°í½Í´Ù
12/25 91
1595   [pwnable.kr] Shellshock[1]     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/23 223
1594   ShellshockÀÇ ±âº» ¿ä¾à     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/23 190
1593   [pwnable.kr] fd     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/23 181
1592   VPNÀÌ ¿¬°áµÇ¾ú´Ù°¡ µµÁß¿¡ ²¨µµ À¥ ºê¶ó¿ìÀú»ó¿¡¼­ À¯ÁöµÇ´Â ÀÌÀ¯     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/22 182
1591   ÇØÄ¿µéÀÌ ÇØÅ·½Ã »ç¿ëÇÏ´Â µð·ºÅ丮 °ø°£[1]     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/22 225
1590   Keyboard Hooking -part2 - (Python3 ver)     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/20 199
1589   [Windows API] Keyboard Hooking     ÇØÅ·ÀßÇÏ°í½Í´Ù
11/20 175
1588   [pwnable.kr] cmd1 °ø·«     ÇØÅ·ÀßÇÏ°í½Í´Ù
10/23 357
1587   netdiscover ÆÄÀ̽ãÀ¸·Î ±¸ÇöÇϱ⠠   ÇØÅ·ÀßÇÏ°í½Í´Ù
08/13 628
1586   ÆÄÀ̽ãÀ» ÀÌ¿ëÇÑ ½ÉÇà À¥ Å©·Ñ·¯     ÇØÅ·ÀßÇÏ°í½Í´Ù
08/13 507
1585   ÆÄÀ̽ã random¸ðµâÀ» ÀÌ¿ëÇÑ ¼ýÀÚ¸ÂÃ߱⠰ÔÀÓ ±¸Çö     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/30 1059
1584   ÆÄÀ̽ã äÆà ÇÁ·Î±×·¥ ±¸Çö     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/28 959
1583   ÆÄÀ̽㠼ÒÄÏ ÇÁ·Î±×·¡¹ÖÀÇ ±âÃÊ     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/26 1112
1582   ¸®´ª½º À¥ ·Î±× ºÐ¼®     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/20 735
1581   ¸®´ª½º/À©µµ¿ì º¸¾È Àåºñ ·Î±×     ÇØÅ·ÀßÇÏ°í½Í´Ù
05/20 894
1 [2][3][4][5][6][7][8][9][10]..[80]

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