How to add an extra 1 to the first and an extra 0 to the last of bitset?
I've written the following code using bitset.I want to add an extra 1 to the first and an extra 0 to the last of the bitset.
Example: 000000000001; this will be 10000000000010
How to do it?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
while(1)
{
unsigned long long num;
cin>>num;
cout<<bitset<64>(num)<<endl;
bitset<64>bits(num);
cout<<bits.count()<<endl;
}
return 0;
}
|
Last edited on
Topic archived. No new replies allowed.