Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- uint16_t concat(uint8_t fi, uint8_t se) {
- uint16_t ans = 0;
- for (int i = 0; i < 8; i++) {
- if (fi & (1 << i)) {
- ans |= 1 << i;
- }
- }
- for (int i = 8; i < 16; i++) {
- if (se & (1 << (i - 8))) {
- ans |= 1 << i;
- }
- }
- return ans;
- }
- void printBits(uint16_t x) {
- for (int i = 15; i >= 0; i--) {
- printf("%d", (x >> i) & 1);
- }
- puts("");
- }
- int main() {
- uint8_t fi, se;
- scanf("%hhd %hhd", &fi, &se);
- printBits(fi);
- printBits(se);
- printBits(concat(fi, se));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement