例子:取8的各个二进制位
#include<bits/stdc++.h> using namespace std; int main() { int n = 8; for(int i=3;i>=0;i--) printf("%d ",n>>i&1); }