#include <stdio.h> #include <stdint.h> uint8_t reverse_bits(uint8_t val) { int res = 0; int n = -1; while (++n < 8) res |= ((val >> n) & 1) << 7 - n; return res; } int main() { uint8_t val; scanf("%hhu", &val); uint8_t result = reverse_bits(val); printf("%u", result); return 0; }
Test Cases
Test Results
Input
26
Expected Output
88