#include <stdio.h> #include <stdint.h> uint16_t spread_bits(uint8_t val) { // Your logic here uint16_t temp = (uint16_t)val; uint16_t reg = 0; int n = 7; for(n; n>=0;n--) { reg |= ((temp & (1<<n)) << (n)); //printf ("%u\n",reg); //Just added here for debug } 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