Skip to content

Instantly share code, notes, and snippets.

@HongfeiXu
Last active January 25, 2018 08:42
Show Gist options
  • Save HongfeiXu/c2d39deb23b0018b46931dc97f405388 to your computer and use it in GitHub Desktop.
Save HongfeiXu/c2d39deb23b0018b46931dc97f405388 to your computer and use it in GitHub Desktop.
cout Binary\Octal\Hexadecimal
#include <bitset>
#include <iostream>
using namespace std;
void outbin(const int x) { cout << bitset<sizeof(int) * 8>(x) << endl; } // 二进制输出
void outoct(const int x) { cout << oct << x << endl; } // 八进制输出
void outhex(const int x) { cout << hex << x << endl; } // 十六进制输出
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment