April Fools Contest 2017, problem: (B) Kids’ Riddle Solution in C

#include<stdio.h>

int main(void)
{
unsigned x, y, result = 0;
scanf(“%u”, &x);
do {
y = x & 15;
x >>= 4;
if (y == 0 || y == 4 || y == 6 || y == 9 || y == 10 || y == 13){
result++;
}
if (y == 8 || y == 11){
result += 2;
}
} while (x);
printf(“%d”, result);
}

(Visited 66 times, 1 visits today)

About the Author:

Leave A Comment