note-20201129

2020-11-29 | Share to Twitter
// 10进制-->m进制
#include <bits/stdc++.h>

using namespace std;

char c[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

void trans(int m, int n)
{
    int r = n%m;
    n = n/m;
    if(n!=0) f(n,m);
    putchar(c[r]);
}

int main()
{
    int m,n;
    scanf("%d %d", &m , &n);
    trans(m,n);
}


// 数字的倒数第k位
#include <bits/stdc++.h>

using namespace std;

int digit(int n, int k)
{
    k = k-1;
    if(k==0) return n%10;
    else return digit(n/10,k);
}

int main()
{
    cout << digit(123456, 2);
    return 0;
}