void trans(int n, int m);
int main()
{
int n;
cin >> n;
trans(n, 2);
cout << endl;
trans(n, 8);
cout << endl;
trans(n, 16);
return 0;
}
void trans(int n, int m)
{
char s[17] = "0123456789ABCDEF";
int len = 0, tmp = n;
while (tmp)
{len++; tmp /= m;}
for (int i = len; i > 0; i--)
**{cout << s[n / (int)pow(m, i - 1)];** 划重点
n %= (int)pow(m, i - 1);}
}
cout << s[n / (int)pow(m, i - 1)];
n %= (int)pow(m, i - 1);
这一段是可以完美输出m进制