Compare commits

..

4 commits

Author SHA1 Message Date
afb500c7ca cpp: ex2: add solution 2022-11-21 17:12:19 +01:00
4950125379 cpp: ex1: add solution 2022-11-21 17:11:03 +01:00
13348109d1 c: ex3: add solution 2022-11-21 17:03:27 +01:00
558be63805 c: ex2: add solution 2022-11-21 16:38:13 +01:00

View file

@ -4,8 +4,9 @@
static unsigned char reverse_byte(unsigned char c) {
unsigned char res = 0;
for (size_t i = 0; i < CHAR_BIT; ++i) {
unsigned char bit = (c & (1 << i));
res |= bit << (CHAR_BIT - i - 1);
res <<= 1;
res |= c & 1;
c >>= 1;
}
return res;
}