123. Funny Encryption Method

 avatar
user_6817964
c_cpp
2 years ago
542 B
1
Indexable
Never
int bin(int N);
int hex(int N);


int bin(int N) {
    int count = 0;
    while (N > 0)
    {
        int temp = N % 2;
        if (temp == 1) {
            count++;
        }
        N /= 2;
    }
    return count;
}
int hex(int N) {
    int count = 0;
    while (N > 0)
    {
        int temp = N % 10;
        count += bin(temp);
        N /= 10;
    }
    return count;
}

int main() {
    int N, b1, b2;
    scanf("%d", &N);
    b1 = bin(N);
    b2 = hex(N);
    printf("%d %d", b1, b2);
    return 0;
}