#include <stdio.h> #include <stdint.h> uint16_t spread_bits(uint8_t val) { uint16_t reg = 0; for(int i = 7; i >= 0; i--) { // Get the bit uint8_t bit = (val >> i) & 0x01; reg |= (bit << (i*2)); } return reg; } int main() { uint8_t val; scanf("%hhu", &val); uint16_t result = spread_bits(val); printf("%u", result); return 0; }
Test Cases
Test Results
Input
202
Expected Output
20548