Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int num[10] = {0,1,2,3,4,5,6,7,8,9};
- const int bits = 5;
- const int max = 1<<bits;
- std::string tobits (int i) {
- std::string s="";
- char ch;
- int b=1;
- while (b<max) {
- if (i & b) ch='1'; else ch='0';
- s=ch+s;
- b<<=1;
- }
- return s;
- }
- int main() {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement