Dec 16, 2016 at 10:36pm UTC
how can i print the representation of number in any-bit binary complement code?
Dec 17, 2016 at 4:48am UTC
i don't want bitset<4> or bitset<8> bitset<16> and etc. i want something like that bitset<n> and i whan i input da n the program output n-bit binary number
Dec 17, 2016 at 12:55pm UTC
Complement code - 1
Given numbers a and n, print the representation of a in n-bit binary complement code.
Print a line with n digits containing the representation of number a in n-bit binary complement code, where the first digit is the highest bit.
Input
In one line given two numbers a and n (2 ≤ n ≤ 16, -2n-1 ≤ a ≤ 2n-1-1).
Output
Print the number in n-bit complement code.
Dec 17, 2016 at 12:55pm UTC
Input example
Sample 1
5 8
Sample 2
-5 8
Output example
Sample 1
00000101
Sample 2
11111011