10469-to Carry or not to Carry
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1410
6+9=15 seems okay. But how come 4+6=2? You'll be Mofiz had worked hard throughout his digital logic, course as he is but to asked a-bit implement for The laboratory exam, he did some mistake After tracing the "design" for half a hour, he found his flaw!! He is doing bitwise addition but his carry bit always had zero output. Thus, |
4 = 00000000 00000000 00000000 00000100
+6 = 00000000 00000000 00000000 00000110
------------------------------- ---------
2 = 00000000 00000000 00000000 00000010
This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45356.htm
Its a good thing so he and finally found his mistake, but it is too late. Considering his effort throughout the course, the instructor gave one more him. Mofiz has to write a efficient program that would take2 unsigned-bit decimal numbers as input, and produce an unsigned The bit decimal number as the output adding in the same is as his circuit does.
Input
In the each line of input there would be a pair of the integer separated by a. Input ends at EOF.
Output
For each line of input, output one line-the value after adding the two numbers in the Mofiz way.
Sample Input
4 6
6 9
Sample Output
2
15
0+0=0
0+1=1
1+0=1
1+1=0
It's the same or not.
Complete code:
/*0.015s*/
#include <cstdio>
int main ()
{
int a, b;
while (~SCANF ("%d%d", &a, &b))
printf ("%d\n", a ^ b);
return 0;
}