Funny Encryption Method
user_3763047219
c_cpp
3 years ago
674 B
6
Indexable
#include <stdio.h>
int bin(int N);
int bin(int N) {
int count = 0;
while (N > 0) {
if (N % 2 == 1) {
count++;
}
N = N / 2;
}
return count;
}
int hex(int N);
int hex(int N) {
int count = 0;
while (N > 0) {
int n16 = N % 10;
while (n16 > 0) {
if (n16 % 2 == 1) {
count++;
}
n16 = n16 / 2;
}
N = N / 10;
}
return count;
}
#include <stdio.h>
int main() {
int N, b1, b2;
scanf("%d", &N);
b1 = bin(N);
b2 = hex(N);
printf("%d %d", b1, b2);
return 0;
}Editor is loading...