fork download
  1. #include <iostream>
  2. #include <bitset>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. constexpr size_t length = 16;
  8. bool input[length]={0};
  9. input[5]=true;
  10. bitset<length> bits;
  11. for(size_t i=0;i<length;++i )
  12. {
  13. bits[i]=input[i];
  14. }
  15. cout << oct << bits.to_ulong() << endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 4976KB
stdin
Standard input is empty
stdout
40