#include<bits/stdc++>
//对x操作数,求出第n位的值为0还是1
#define getBit(x, n) ((x >> n) & 1)
//对x操作数,置第n位为1
#define setBit(x, n) (x | (1 << n))
using namespace std;
int main(){
freopen("in.txt","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0);
int a = 2;
cout<<getBit(a,0)<<endl;
cout<<getBit(a,1)<<endl;
a = setBit(a,0);
cout<<a<<endl;
return 0;
}
C++ 刷题板子
于 2022-06-01 08:31:52 首次发布