hdu2031

http://acm.hdu.edu.cn/showproblem.php?pid=2031

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<string.h>
 4 #include<stdlib.h>
 5 #include<iostream>
 6 using namespace std;
 7 
 8 int main()
 9 {
10     //freopen("in.txt","r",stdin);
11     int n,r;
12     int a[100];
13     while(~scanf("%d%d",&n,&r))
14     {
15         memset(a,0,sizeof(a));
16         int fh=0;
17         if(n<0)
18         {
19             n=-n;
20             fh=1;
21         }
22         int t=0;
23         while(1)
24         {
25             a[t++]=n%r;
26             if(n/r==0)
27             break;
28             n=n/r;
29         }
30         if(fh==1)
31         printf("-");
32         for(int i=t-1;i>=0;i--)
33         {
34             if(a[i]<10)
35             printf("%d",a[i]);
36             else
37             {
38                 int q=a[i]+55;
39                 printf("%c",q);
40             }
41         }
42         printf("\n");
43     }
44     return 0;
45 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值