HDU 1877 又一版 A+B(进制转换)

看了http://lovnet.iteye.com/blog/1690276的答案

好巧妙的方法

递归实现十进制向m进制转换

#include "stdio.h"
int m;
void CK(int n)
{
    if(n>=m)
        CK(n/m);
    printf("%d",n%m);
}
int main()
{
    int a,b;
    while(~scanf("%d",&m)&&m)
    {
        scanf("%d%d",&a,&b);
        CK(a+b);
        printf("\n");
    }
    return 0;
}

 

posted @ 2017-03-18 17:23  kimsimple  阅读(190)  评论(0编辑  收藏  举报