專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

異或妙用

作者:佚名   來源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2013年11月03日   【字體:

#include <string.h>
void main(void)
{
 int a=15,b=24;
 printf("a=%d b=%d\n",a,b);
 a=a^b;
 b=b^a;
 a=a^b;
 printf("a=%d b=%d\n",a,b);
}

a=15   0000 1111  ^

b=24   0001 1000

           0001 0111    =23

           0000 1111   =15

           0001 1000    =24

 

關(guān)閉窗口

相關(guān)文章