Compare commits

..

4 commits

Author SHA1 Message Date
77b3f80ccc cpp: ex2: add solution 2022-11-30 14:15:55 +01:00
8259ab1614 cpp: ex1: add solution 2022-11-30 14:15:55 +01:00
c4a3886504 c: ex3: add solution 2022-11-30 14:15:55 +01:00
0249bf45e7 c: ex2: add solution 2022-11-21 16:41:49 +01:00

View file

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