parent
f6fe46eb57
commit
1c45b02b12
@ -0,0 +1,37 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in new issue