#include using namespace std; int main() { int n = 5; int s = 13; for (int i = n - 1; i >= 0; i--) //5位 if (s & (1 << i)) //0还是非0 cout << 1 << " "; else cout << 0 << " "; return 0; }