forked from wisdompeak/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename Convert_to_Binary_String.cpp to bitset.cpp
- Loading branch information
1 parent
a32d349
commit b2e4dd4
Showing
2 changed files
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
bitset<100>bs; // define a bitset type | ||
|
||
std::string str = std::bitset<32>(n).to_string(); // convert an integer n to bitset type, and then to string type | ||
|
||
bs.set(); // make every bit as 1 | ||
|
||
bs.count(); // count the number of 1-bits in bs |