You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
466 B
37 lines
466 B
#include<stdio.h>
|
|
int main(/*int argc, char **argv*/)
|
|
{
|
|
int N=0,R=0;
|
|
char ch[33];
|
|
int count = 0;
|
|
scanf("%d%d",&N,&R);
|
|
int neg = 0;
|
|
if(N<0)
|
|
{
|
|
neg = 1;
|
|
N = -N;
|
|
}
|
|
while(N!=0)
|
|
{
|
|
int cur=N%R;
|
|
if(cur>=10)
|
|
{
|
|
ch[count]=cur - 10 + 'A';
|
|
}
|
|
else
|
|
{
|
|
ch[count]=cur + '0';
|
|
}
|
|
N/=R;
|
|
count++;
|
|
}
|
|
if(neg == 1)
|
|
{
|
|
printf("-");
|
|
}
|
|
for( int i = count - 1 ; i >= -1 ;--i)
|
|
{
|
|
printf("%c",ch[i]);
|
|
}
|
|
return 0;
|
|
} |