私は C++ で最初のステップを実行しており、いくつかの助けを借りて、簡単な関数を作成するコードを作成しました。しかし、私には問題があります。特定のライブラリを必要とするビットセット関数を使用していますが、このライブラリをコードに導入する担当者がわかりません。
ネットで情報を読んでいるのですが、うまくいかないので、詳しい方法を教えていただけないでしょうか。
あなたが私が見てきたアイデアを作るためにhttp://www.boost.org/doc/libs/1_36_0/libs/dynamic_bitset/dynamic_bitset.html、http://www.boost.org/doc/libs/1_46_0 /libs/dynamic_bitset/dynamic_bitset.html#cons2および同様の場所。
コードを添付して、私が何をしているのかを理解してもらいます。
前もって感謝します :)
// Program that converts a number from decimal to binary and show the positions where the bit of the number in binary contains 1
#include<iostream>
#include <boost/dynamic_bitset.hpp>
int main() {
unsigned long long dec;
std::cout << "Write a number in decimal: ";
std::cin >> dec;
boost::dynamic_bitset<> bs(64, dec);
std::cout << bs << std::endl;
for(size_t i = 0; i < 64; i++){
if(bs[i])
std::cout << "Position " << i << " is 1" << std::endl;
}
//system("pause");
return 0;
}