位运算

来源:互联网 发布:淘宝充话费等级 编辑:程序博客网 时间:2024/06/07 06:56


#include<iostream>#include<stdio.h>#include<string>using namespace std;int main(){unsigned result;int a = 2, b = 4, c = 6, d = 8;cout << "---------------------------" << endl;cout << "|a=%d,b=%d,c=%d,d=%d" << a << b << c << d << endl;cout << "|--------------------------" << endl;cout << "------输出运算符------------" << endl;result = a&b;cout << "result=a&b=   %d" << result << "   " << endl;result = b | d;cout << "result=b | d=    %d" << result << "   " << endl;result = a^d;cout << "result=a^d=     %d" << result << "   " << endl;result = ~a;cout << "result= ~a=%d" << result << "   " << endl;    system("pause");return 0;}


0 0
原创粉丝点击