#include <iostream>
using namespace std;
int main()
{
int n, r;
char c[1000];
while (cin >> n >> r)
{
int i = 0;
int t = 0;
if (n < 0)
{
n = abs(n);
t = 1;
}
while (n)
{
int f = n % r;
n = n / r;
if (f >= 10)
c[i++] = f - 10 + 'A';
else
c[i++] = f + '0';
}
for (int j = i - 1; j >= 0; j--)
{
if (t)
{
cout << '-';
t = 0;
}
cout << c[j];
}
cout << endl;
}
return 0;
}
hdu 31 进制转换
最新推荐文章于 2024-07-24 14:05:37 发布