Latest web development tutorials

C 練習實例53

C 語言經典100例 C語言經典100例

題目:學習使用按位異或^。

程序分析: 0^0=0; 0^1=1; 1^0=1; 1^1=0 。

程序源代碼:

//  Created by www.w3big.com on 15/11/9.
//  Copyright © 2015年 本教程. All rights reserved.
//

#include <stdio.h>
int main()
{
    int a,b;
    a=077;
    b=a^3;
    printf("b 的值为 %d \n",b);
    b^=7;
    printf("b 的值为 %d \n",b);
    return 0;
}

以上實例輸出結果為:

b 的值为 60 
b 的值为 59 

C 語言經典100例 C語言經典100例