#include <bitset> #include <iostream> #include <string> template <typename T> std::string getBinary(T t) { unsigned long val = t; std::bitset<8 * sizeof t> bits(val); return bits.to_string(); } int main() { using namespace std; while (cin) { unsigned short x; cin >> x; cout << getBinary(x) << '\n'; } }
No comments:
Post a Comment